예제 #1
0
파일: client.py 프로젝트: sgallet/pychron
    def _parse_propfind(self, resp):
        parser = XMLParser()

        parser.load(resp)
        tree = parser.get_tree()

        name = '{{DAV:}}{}'.format
        def get_response_name(elem):
            href = elem.find(name('href'))
            path = href.text.strip()
            return os.path.basename(path)

        return [get_response_name(ri) for ri in tree.findall(name('response'))]
예제 #2
0
    def _path_changed(self, new):
        self.datasource_url = 'Invalid Path'
        if new:
            if os.path.isfile(new):
                self.datasource_url = os.path.join(os.path.basename(os.path.dirname(new)), os.path.basename(new))

                self._parser = XMLParser(new)

                self._load_projects()
                self._load_mass_spectrometers()
                self._load_irradiations()

                self._load_sample_meta()
예제 #3
0
 def load(self, path):
     self.reset_layers()
     parser = XMLParser(path)
     self._load_detectors(parser)
예제 #4
0
    def __init__(self, *args, **kw):
        super(XMLExporter, self).__init__(*args, **kw)
        from pychron.core.xml.xml_parser import XMLParser

        xmlp = XMLParser()
        self._parser = xmlp
예제 #5
0
 def _assemble_xml(self):
     return 'asfafasfafsd'
     xp = XMLParser()
     return xp.tostring()
예제 #6
0
 def _assemble_xml(self):
     return 'asfafasfafsd'
     xp = XMLParser()
     return xp.tostring()
예제 #7
0
def get_parser():
    p = os.path.join(paths.setup_dir, 'dashboard.xml')
    parser = XMLParser(p)
    return parser
예제 #8
0
class XMLDatabase(Loggable):
    kind = None
    path = Str

    projects = List
    samples = List
    irradiations = List
    mass_spectrometers = List

    _parser = Instance(XMLParser)

    def _path_changed(self, new):
        self.datasource_url = 'Invalid Path'
        if new:
            if os.path.isfile(new):
                self.datasource_url = os.path.join(os.path.basename(os.path.dirname(new)), os.path.basename(new))

                self._parser = XMLParser(new)

                self._load_projects()
                self._load_mass_spectrometers()
                self._load_irradiations()

                self._load_sample_meta()

    def make_analyses(self, ans, **kw):
        return self.get_analyses_uuid([ai.identifier for ai in ans], klass=XMLAnalysis)

    # DatabaseAdapter interface
    def session_ctx(self, *args, **kw):
        return MockSession()

    def get_projects(self, *args, **kw):
        return self.projects

    def get_mass_spectrometers(self):
        return self.mass_spectrometers

    def get_irradiations(self, *args, **kw):
        return self.irradiations

    def get_project_date_range(self, names):
        dt = datetime.now()
        return dt, dt

    def get_project_labnumbers(self, projects, filter_non_run_samples=None, lp=None, hp=None,
                               analysis_types=None,
                               mass_spectrometers=None):
        elems = self._parser.get_elements('Sample')

        return [XMLLabnumber(i) for i in elems]

    def get_labnumber_analyses(self, lns, **kw):
        for li in lns:
            elems = self._parser.get_elements('Sample')
            for e in elems:
                if e.get('igsn') == li:
                    ms = e.xpath('Parameters/Experiment/Measurement')
                    ans = [XMLAnalysisRecord(e, mi) for mi in ms]
                    return ans, len(ans)

    def get_analysis_groups(self, *args, **kw):
        return []

    def get_analyses_uuid(self, uuids, klass=None):
        if klass is None:
            klass = XMLAnalysisRecord

        ms = self._parser.get_elements('Parameters/Experiment/Measurement')
        ans = []

        for ui in uuids:
            mi = next((mi for mi in ms if mi.get('measurementNumber') == ui))

            cur = mi
            while 1:
                elem = cur.getparent()
                if elem.tag == 'Sample':
                    break
                else:
                    cur = elem
            # elem = next((ei for ei in elems if ei.get('')))
            ans.append(klass(elem, mi))

        return ans

    def get_labnumber_figures(self, lns):
        return []

    # private
    def _load_projects(self):
        elem = self._parser.get_elements('Parameters/Experiment')
        self.projects = [XMLProjectRecordView(i.get('projectName')) for i in elem]

    def _load_irradiations(self):
        elem = self._parser.get_elements('Parameters/Experiment/Irradiation')
        self.irradiations = [XMLIrradiationRecordView(i.get('irradiationName')) for i in elem]

    def _load_mass_spectrometers(self):
        elem = self._parser.get_elements('Parameters/Experiment')
        self.mass_spectrometers = [XMLSpectrometerRecord(i.get('massSpectrometer')) for i in elem]

    def _load_sample_meta(self):
        elem = self._parser.get_elements('Sample')
        pass