예제 #1
0
파일: iso.py 프로젝트: b-cube/pipeline-demo
    def __init__(self, ct):
        val = ct.find(util.nspath_eval('gmx:name/gco:CharacterString', namespaces))
        self.name = util.testXMLValue(val)
        val = ct.find(util.nspath_eval('gmx:scope/gco:CharacterString', namespaces))
        self.scope = util.testXMLValue(val)
        val = ct.find(util.nspath_eval('gmx:fieldOfApplication/gco:CharacterString', namespaces))
        self.fieldapp = util.testXMLValue(val)
        val = ct.find(util.nspath_eval('gmx:versionNumber/gco:CharacterString', namespaces))
        self.version = util.testXMLValue(val)
        val = ct.find(util.nspath_eval('gmx:versionDate/gco:Date', namespaces))
        self.date = util.testXMLValue(val)

        self.dictionaries = {}

        for i in ct.findall(util.nspath_eval('gmx:codelistItem/gmx:CodeListDictionary', namespaces)):
            id = i.attrib.get(util.nspath_eval('gml32:id', namespaces))
            self.dictionaries[id] = {}
            val = i.find(util.nspath_eval('gml32:description', namespaces))
            self.dictionaries[id]['description'] = util.testXMLValue(val)
            val = i.find(util.nspath_eval('gml32:identifier', namespaces))
            self.dictionaries[id]['identifier'] = util.testXMLValue(val)
            self.dictionaries[id]['entries'] = {}

            for j in i.findall(util.nspath_eval('gmx:codeEntry', namespaces)):
                id2 = j.find(util.nspath_eval('gmx:CodeDefinition', namespaces)).attrib.get(util.nspath_eval('gml32:id', namespaces))
                self.dictionaries[id]['entries'][id2] = {}
                val = j.find(util.nspath_eval('gmx:CodeDefinition/gml32:description', namespaces))
                self.dictionaries[id]['entries'][id2]['description'] = util.testXMLValue(val)

                val = j.find(util.nspath_eval('gmx:CodeDefinition/gml32:identifier', namespaces))
                self.dictionaries[id]['entries'][id2]['identifier'] = util.testXMLValue(val)

                val = j.find(util.nspath_eval('gmx:CodeDefinition', namespaces)).attrib.get('codeSpace')
                self.dictionaries[id]['entries'][id2]['codespace'] = util.testXMLValue(val, True)
예제 #2
0
    def parse_siteinfo(self, xml=None):
        if xml is not None:
            try:
                self._root = etree.parse(xml)
            except:
                self._root = xml

        # try:
        xml_dict = _xml_to_dict(self._root)
        self.site_name = xml_dict.get('site_name')
        self.site_codes = [
            testXMLValue(code) for code in self._findall('siteCode')
        ]
        self.elevation = xml_dict.get('elevation_m')
        self.vertical_datum = xml_dict.get('vertical_datum')
        self.site_types = [
            testXMLValue(typ) for typ in self._findall('siteType')
        ]
        self.site_properties = dict([
            (prop.attrib.get('name'), testXMLValue(prop))
            for prop in self._findall('siteProperty')
        ])
        self.altname = xml_dict.get('altname')
        self.notes = [testXMLValue(note) for note in self._findall('note')]
        # sub-objects
        tzi = self._find('timeZoneInfo')
        if tzi is not None:
            self.time_zone_info = TimeZoneInfo(tzi, self._ns)

        self.location = Location(self._find('geoLocation'), self._ns)
예제 #3
0
    def __init__(self, md=None):
        if md is None:
            self.url = None
            self.protocol = None
            self.name = None
            self.description = None
            self.function = None
        else:
            val = md.find(util.nspath_eval('gmd:linkage/gmd:URL', namespaces))
            self.url = util.testXMLValue(val)

            val = md.find(
                util.nspath_eval('gmd:protocol/gco:CharacterString',
                                 namespaces))
            self.protocol = util.testXMLValue(val)

            val = md.find(
                util.nspath_eval('gmd:name/gco:CharacterString', namespaces))
            self.name = util.testXMLValue(val)

            val = md.find(
                util.nspath_eval('gmd:description/gco:CharacterString',
                                 namespaces))
            self.description = util.testXMLValue(val)

            self.function = _testCodeListValue(
                md.find(
                    util.nspath_eval('gmd:function/gmd:CI_OnLineFunctionCode',
                                     namespaces)))
예제 #4
0
    def __init__(self, md):
        val = md.find(util.nspath_eval('dif:File', namespaces))
        self.file = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:URL', namespaces))
        self.url = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Format', namespaces))
        self.format = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Caption', namespaces))
        self.caption = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Description', namespaces))
        self.description = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Visualization_URL', namespaces))
        self.vis_url = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Visualization_Type', namespaces))
        self.vis_type = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Visualization_Subtype', namespaces))
        self.vis_subtype = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Visualization_Duration', namespaces))
        self.vis_duration = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Visualization_File_Size', namespaces))
        self.file_size = util.testXMLValue(val)
예제 #5
0
    def __init__(self, md=None):
        if md is None:
            self.format = None
            self.version = None
            self.distributor = []
            self.online = []
            pass
        else:
            val = md.find(
                util.nspath_eval(
                    'gmd:distributionFormat/gmd:MD_Format/gmd:name/gco:CharacterString',
                    namespaces))
            self.format = util.testXMLValue(val)

            val = md.find(
                util.nspath_eval(
                    'gmd:distributionFormat/gmd:MD_Format/gmd:version/gco:CharacterString',
                    namespaces))
            self.version = util.testXMLValue(val)

            self.distributor = []
            for dist in md.findall(
                    util.nspath_eval('gmd:distributor', namespaces)):
                self.distributor.append(MD_Distributor(dist))

            self.online = []

            for ol in md.findall(
                    util.nspath_eval(
                        'gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource',
                        namespaces)):
                self.online.append(CI_OnlineResource(ol))
예제 #6
0
    def __init__(self, infoset):
        self._root = infoset
        self.name = testXMLValue(self._root.find(nspath('Name')))
        self.url = testXMLValue(self._root.find(nspath('OnlineResource')))
        self.keywords = extract_xml_list(self._root.find(nspath('Keywords')))

        # no contact info in this version of the spec
        self.contact = None
예제 #7
0
    def __init__(self, infoset):
        self._root = infoset
        self.name = testXMLValue(self._root.find(nspath('Name')))
        self.url = testXMLValue(self._root.find(nspath('OnlineResource')))
        self.keywords = extract_xml_list(self._root.find(nspath('Keywords')))

        # no contact info in this version of the spec
        self.contact = None
예제 #8
0
 def __init__(self, infoset, version):
     self._root = infoset
     self.type = testXMLValue(self._root.find(nspath('Name', WMS_NAMESPACE)))
     self.version = version
     self.title = testXMLValue(self._root.find(nspath('Title', WMS_NAMESPACE)))
     self.abstract = testXMLValue(self._root.find(nspath('Abstract', WMS_NAMESPACE)))
     self.keywords = extract_xml_list(self._root.findall(nspath('KeywordList/Keyword', WMS_NAMESPACE)))
     self.accessconstraints = testXMLValue(self._root.find(nspath('AccessConstraints', WMS_NAMESPACE)))
     self.fees = testXMLValue(self._root.find(nspath('Fees', WMS_NAMESPACE)))
예제 #9
0
    def __init__(self, md):
        val = md.find('abstract')
        self.abstract = util.testXMLValue(val)
        
        val = md.find('purpose')
        self.purpose = util.testXMLValue(val)

        val = md.find('supplinf')
        self.supplinf = util.testXMLValue(val)
예제 #10
0
    def __init__(self, md):
        val = md.find('abstract')
        self.abstract = util.testXMLValue(val)

        val = md.find('purpose')
        self.purpose = util.testXMLValue(val)

        val = md.find('supplinf')
        self.supplinf = util.testXMLValue(val)
예제 #11
0
 def __init__(self, md):
     val = md.find('begdate')
     self.begdate = util.testXMLValue(val)
     val = md.find('begtime')
     self.begtime = util.testXMLValue(val)
     val = md.find('enddate')
     self.enddate = util.testXMLValue(val)
     val = md.find('endtime')
     self.endtime = util.testXMLValue(val)
예제 #12
0
    def __init__(self, md):
        val = md.find(util.nspath_eval('dif:Discipline_Name', namespaces))
        self.name = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Subdiscipline', namespaces))
        self.subdiscipline = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Detailed_Subdiscipline', namespaces))
        self.detailed_subdiscipline = util.testXMLValue(val)
예제 #13
0
 def __init__(self, element):
     super(AllowedTokens, self).__init__(element)
     self.value = filter(
         None,
         [testXMLValue(x) for x in element.findall(nspv("swe20:value"))
          ])  # string, min=0, max=X
     self.pattern = testXMLValue(
         element.find(nspv("swe20:pattern"))
     )  # string (Unicode Technical Standard #18, Version 13), min=0
예제 #14
0
 def __init__(self, element):
     super(AbstractSWEIdentifiable, self).__init__(element)
     # Elements
     self.identifier = testXMLValue(element.find(
         nspv("swe20:identifier")))  # anyURI, min=0
     self.label = testXMLValue(element.find(
         nspv("swe20:label")))  # string, min=0
     self.description = testXMLValue(element.find(
         nspv("swe20:description")))  # string, min=0
예제 #15
0
 def __init__(self, infoset, version):
     self._root = infoset
     self.type = testXMLValue(self._root.find(nspath('Name')))
     self.version = version
     self.title = testXMLValue(self._root.find(nspath('Title')))
     self.abstract = testXMLValue(self._root.find(nspath('Abstract')))
     self.keywords = [f.text for f in self._root.findall(nspath('Keywords'))]
     self.fees = testXMLValue(self._root.find(nspath('Fees')))
     self.accessconstraints = testXMLValue(self._root.find(nspath('AccessConstraints')))
예제 #16
0
 def __init__(self, md):
     val = md.find('begdate')
     self.begdate = util.testXMLValue(val)
     val = md.find('begtime')
     self.begtime = util.testXMLValue(val)
     val = md.find('enddate')
     self.enddate = util.testXMLValue(val)
     val = md.find('endtime')
     self.endtime = util.testXMLValue(val)
예제 #17
0
파일: wml.py 프로젝트: b-cube/pipeline-demo
    def parse_variable(self,xml=None):
        if xml is not None:
            try:
                self._root = etree.parse(xml)
            except:
                self._root = xml

        # try:
        xml_dict = _xml_to_dict(self._root)
        self.value_type = xml_dict.get('value_type')
        self.data_type = xml_dict.get('data_type')
        self.general_category = xml_dict.get('general_category')
        self.sample_medium = xml_dict.get('sample_medium')
        self.no_data_value = xml_dict.get('no_data_value')
        self.variable_name = xml_dict.get('variable_name')
        self.variable_code = xml_dict.get('variable_code')
        self.variable_description = xml_dict.get('variable_description')
        self.speciation = xml_dict.get('speciation')
        # notes and properties
        notes = [(note.attrib.get('title'),testXMLValue(note)) for note in self._findall('note')]
        none_notes = [note[1] for note in notes if note[0] is None]
        self.notes = dict([note for note in notes if note[0] is not None])
        if len(none_notes) > 0:
            self.notes['none'] = none_notes

        self.properties = dict([(prop.attrib.get('name'),testXMLValue(prop)) for prop in self._findall('variableProperty')])
        # related
        related = self._find('related')
        if related is not None:
            self.parent_codes = [dict([('network',code.attrib.get('network')),('vocabulary',code.attrib.get('vocabulary')),('default',code.attrib.get('default'))])
                             for code in related.findall(ns(self._ns) + 'parentCode')]
            self.related_codes = [dict([('network',d.get('network')),('vocabulary',d.get('vocabulary')),('default',d.get('default'))])
                             for code in related.findall(ns(self._ns) + 'relatedCode')]
        else:
            self.parent_codes = None
            self.related_codes = None

        # sub-objects
        if self._ns == 'wml1.0':
            unit = self._find('units')
            self.unit = Unit1_0(unit, self._ns) if unit is not None else None

            timesupport = self._find('timeSupport')
            self.time_support = TimeScale(timesupport, self._ns) if timesupport is not None else None
        else:
            unit = self._find('unit')
            self.unit = Unit(unit, self._ns) if unit is not None else None

            timescale = self._find('timeScale')
            self.time_scale = TimeScale(timescale, self._ns) if timescale is not None else None

        categories = self._find('categories')
        if categories is not None:
            self.categories = [Category(cat,self._ns) for cat in categories.findall(ns(self._ns) + 'category')]
        else:
            self.categories = None
예제 #18
0
파일: iso.py 프로젝트: b-cube/pipeline-demo
def _testCodeListValue(elpath):
    """ get gco:CodeListValue_Type attribute, else get text content """
    if elpath is not None:  # try to get @codeListValue
        val = util.testXMLValue(elpath.attrib.get('codeListValue'), True)
        if val is not None:
            return val
        else:  # see if there is element text
            return util.testXMLValue(elpath)
    else:
        return None
예제 #19
0
def _testCodeListValue(elpath):
    """ get gco:CodeListValue_Type attribute, else get text content """
    if elpath is not None:  # try to get @codeListValue
        val = util.testXMLValue(elpath.attrib.get('codeListValue'), True)
        if val is not None:
            return val
        else:  # see if there is element text
            return util.testXMLValue(elpath)
    else:
        return None
예제 #20
0
파일: wml.py 프로젝트: b-cube/pipeline-demo
 def parse_contactinformation(self):
     try:
         xml_dict = _xml_to_dict(self._root)
         self.name = xml_dict.get('contact_name')
         self.type = xml_dict.get('type_of_contact')
         self.email = [testXMLValue(email) for email in self._findall('email')]
         self.phone = [testXMLValue(phone) for phone in self._findall('phone')]
         self.address = [testXMLValue(address) for address in self._findall('address')]
     except:
         raise
예제 #21
0
    def __init__(self, md):
        val = md.find(util.nspath_eval('dif:Paleo_Start_Date', namespaces))
        self.paleo_start_date = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Paleo_End_Date', namespaces))
        self.paleo_end_date = util.testXMLValue(val)

        self.chronostratigraphic_unit = []
        for el in md.findall(util.nspath_eval('dif:Chronostratigraphic_Unit', namespaces)):
            self.chronostratigraphic_unit.append(Chronostratigraphic_Unit(el))
예제 #22
0
    def __init__(self, md):
        self.content_type = []
        for el in md.findall(util.nspath_eval('dif:URL_Content_Type', namespaces)):
            self.content_type.append(URL_Content_Type(el))

        val = md.find(util.nspath_eval('dif:URL', namespaces))
        self.url = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Description', namespaces))
        self.description = util.testXMLValue(val)
예제 #23
0
 def _parsetransactionsummary(self):
     val = self._exml.find(util.nspath_eval('csw:TransactionSummary', namespaces))
     if val is not None:
         rid = val.attrib.get('requestId')
         self.results['requestid'] = util.testXMLValue(rid, True)
         ts = val.find(util.nspath_eval('csw:totalInserted', namespaces))
         self.results['inserted'] = int(util.testXMLValue(ts))
         ts = val.find(util.nspath_eval('csw:totalUpdated', namespaces))
         self.results['updated'] = int(util.testXMLValue(ts))
         ts = val.find(util.nspath_eval('csw:totalDeleted', namespaces))
         self.results['deleted'] = int(util.testXMLValue(ts))
예제 #24
0
 def __init__(self, elem):
     # properties
     self.type = 'OGC:WCS'
     self.version = '1.0.0'
     self.service = testXMLValue(elem.find(ns('name')))
     self.abstract = testXMLValue(elem.find(ns('description')))
     self.title = testXMLValue(elem.find(ns('label')))
     self.keywords = [f.text for f in elem.findall(ns('keywords') + '/' + ns('keyword'))]
     # note: differs from 'rights' in interface
     self.fees = elem.find(ns('fees')).text
     self.accessconstraints = elem.find(ns('accessConstraints')).text
예제 #25
0
 def __init__(self, infoset,namespace=DEFAULT_OWS_NAMESPACE):
     self._root = infoset
     val = self._root.find(util.nspath('ProviderName', namespace))
     self.name = util.testXMLValue(val)
     self.contact = ServiceContact(infoset, namespace)
     val = self._root.find(util.nspath('ProviderSite', namespace))
     if val is not None:
         urlattrib=val.attrib[util.nspath('href', XLINK_NAMESPACE)]
         self.url = util.testXMLValue(urlattrib, True)
     else:
         self.url =None
예제 #26
0
 def __init__(self, md):
     val = md.find('distinfo')
     if val is not None:
         val2 = val.find('stdorder')
         if val2 is not None:
             self.stdorder = {'digform': []}
             for link in val2.findall('digform'):
                 digform = {}
                 digform['name'] = util.testXMLValue(link.find('digtinfo/formname'))
                 digform['url'] = util.testXMLValue(link.find('digtopt/onlinopt/computer/networka/networkr/'))
                 self.stdorder['digform'].append(digform)
예제 #27
0
파일: sml.py 프로젝트: b-cube/pipeline-demo
 def __init__(self, element):
     self.id          = testXMLAttribute(element, nsp("gml:id"))
     self.version     = testXMLValue(element.find(nsp("sml:version")))
     self.description = testXMLValue(element.find(nsp("gml:description")))
     self.date        = testXMLValue(element.find(nsp("sml:date")))
     try:
         self.contact     = Contact(element.find(nsp("sml:contact")))
     except AttributeError:
         self.contact     = None
     self.format      = testXMLValue(element.find(nsp('sml:format')))
     self.url         = testXMLAttribute(element.find(nsp('sml:onlineResource')), nsp('xlink:href'))
예제 #28
0
    def __init__(self, elem):
        self.service = "WCS"
        # TODO: fix this
        self.version = "1.1.0"
        self.title = testXMLValue(find(elem, ns('Title')))
        self.abstract = testXMLValue(find(elem, ns('Abstract')))
        self.keywords = [f.text for f in findall(elem, ns('Keywords/Keyword'))]

        self.fees = testXMLValue(find(elem, ns('Fees')))

        self.accessconstraints = testXMLValue(find(elem, ns('AccessConstraints')))
예제 #29
0
 def __init__(self, infoset, version):
     self._root = infoset
     self.type = testXMLValue(self._root.find('Name'))
     self.version = version
     self.title = testXMLValue(self._root.find('Title'))
     self.abstract = testXMLValue(self._root.find('Abstract'))
     self.keywords = extract_xml_list(
         self._root.findall('KeywordList/Keyword'))
     self.accessconstraints = testXMLValue(
         self._root.find('AccessConstraints'))
     self.fees = testXMLValue(self._root.find('Fees'))
예제 #30
0
 def __init__(self, element):
     super(AllowedTimes, self).__init__(element)
     self.value = filter(
         None,
         [testXMLValue(x) for x in element.findall(nspv("swe20:value"))])
     self.interval = filter(None, [
         make_pair(testXMLValue(x))
         for x in element.findall(nspv("swe20:interval"))
     ])
     self.significantFigures = get_int(
         testXMLValue(element.find(
             nspv("swe20:significantFigures"))))  # integer, min=0
예제 #31
0
 def __init__(self, infoset, version):
     self._root = infoset
     self.type = testXMLValue(self._root.find(nspath('Name')))
     self.version = version
     self.title = testXMLValue(self._root.find(nspath('Title')))
     self.abstract = testXMLValue(self._root.find(nspath('Abstract')))
     self.keywords = [
         f.text for f in self._root.findall(nspath('Keywords'))
     ]
     self.fees = testXMLValue(self._root.find(nspath('Fees')))
     self.accessconstraints = testXMLValue(
         self._root.find(nspath('AccessConstraints')))
예제 #32
0
 def __init__(self, element):
     self.id = testXMLAttribute(element, nsp("gml:id"))
     self.version = testXMLValue(element.find(nsp("sml:version")))
     self.description = testXMLValue(element.find(nsp("gml:description")))
     self.date = testXMLValue(element.find(nsp("sml:date")))
     try:
         self.contact = Contact(element.find(nsp("sml:contact")))
     except AttributeError:
         self.contact = None
     self.format = testXMLValue(element.find(nsp('sml:format')))
     self.url = testXMLAttribute(element.find(nsp('sml:onlineResource')),
                                 nsp('xlink:href'))
예제 #33
0
    def __init__(self, ct):
        val = ct.find(
            util.nspath_eval('gmx:name/gco:CharacterString', namespaces))
        self.name = util.testXMLValue(val)
        val = ct.find(
            util.nspath_eval('gmx:scope/gco:CharacterString', namespaces))
        self.scope = util.testXMLValue(val)
        val = ct.find(
            util.nspath_eval('gmx:fieldOfApplication/gco:CharacterString',
                             namespaces))
        self.fieldapp = util.testXMLValue(val)
        val = ct.find(
            util.nspath_eval('gmx:versionNumber/gco:CharacterString',
                             namespaces))
        self.version = util.testXMLValue(val)
        val = ct.find(util.nspath_eval('gmx:versionDate/gco:Date', namespaces))
        self.date = util.testXMLValue(val)

        self.dictionaries = {}

        for i in ct.findall(
                util.nspath_eval('gmx:codelistItem/gmx:CodeListDictionary',
                                 namespaces)):
            id = i.attrib.get(util.nspath_eval('gml32:id', namespaces))
            self.dictionaries[id] = {}
            val = i.find(util.nspath_eval('gml32:description', namespaces))
            self.dictionaries[id]['description'] = util.testXMLValue(val)
            val = i.find(util.nspath_eval('gml32:identifier', namespaces))
            self.dictionaries[id]['identifier'] = util.testXMLValue(val)
            self.dictionaries[id]['entries'] = {}

            for j in i.findall(util.nspath_eval('gmx:codeEntry', namespaces)):
                id2 = j.find(util.nspath_eval('gmx:CodeDefinition',
                                              namespaces)).attrib.get(
                                                  util.nspath_eval(
                                                      'gml32:id', namespaces))
                self.dictionaries[id]['entries'][id2] = {}
                val = j.find(
                    util.nspath_eval('gmx:CodeDefinition/gml32:description',
                                     namespaces))
                self.dictionaries[id]['entries'][id2][
                    'description'] = util.testXMLValue(val)

                val = j.find(
                    util.nspath_eval('gmx:CodeDefinition/gml32:identifier',
                                     namespaces))
                self.dictionaries[id]['entries'][id2][
                    'identifier'] = util.testXMLValue(val)

                val = j.find(util.nspath_eval(
                    'gmx:CodeDefinition', namespaces)).attrib.get('codeSpace')
                self.dictionaries[id]['entries'][id2][
                    'codespace'] = util.testXMLValue(val, True)
예제 #34
0
    def __init__(self, elem):
        self.service = "WCS"
        # TODO: fix this
        self.version = "1.1.0"
        self.title = testXMLValue(find(elem, ns('Title')))
        self.abstract = testXMLValue(find(elem, ns('Abstract')))
        self.keywords = [f.text for f in findall(elem, ns('Keywords/Keyword'))]

        self.fees = testXMLValue(find(elem, ns('Fees')))

        self.accessconstraints = testXMLValue(
            find(elem, ns('AccessConstraints')))
예제 #35
0
    def __init__(self, md):
        val = md.find(util.nspath_eval('dif:Distribution_Media', namespaces))
        self.media = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Distribution_Size', namespaces))
        self.size = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Distribution_Format', namespaces))
        self.format = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Fees', namespaces))
        self.fees = util.testXMLValue(val)
예제 #36
0
    def __init__(self, md):
        val = md.find(util.nspath_eval('dif:Data_Center_Name', namespaces))
        self.name = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Data_Center_URL', namespaces))
        self.url = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Data_Set_ID', namespaces))
        self.data_set_id = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Personnel', namespaces))
        self.personnel = util.testXMLValue(val)
예제 #37
0
    def __init__(self, elem):
        self.name = testXMLValue(
            find(elem, ns('ServiceContact/IndividualName')))

        self.organization = testXMLValue(find(elem, ns('ProviderName')))

        self.address = testXMLValue(
            find(elem, ns('ServiceContact/ContactInfo/Address/DeliveryPoint')))

        self.city = testXMLValue(
            find(elem, ns('ServiceContact/ContactInfo/Address/City')))

        self.region = testXMLValue(
            find(elem,
                 ns('ServiceContact/ContactInfo/Address/AdministrativeArea')))

        self.postcode = testXMLValue(
            find(elem, ns('ServiceContact/ContactInfo/Address/PostalCode')))

        self.country = testXMLValue(
            find(elem, ns('ServiceContact/ContactInfo/Address/Country')))

        self.email = testXMLValue(
            find(
                elem,
                ns('ServiceContact/ContactInfo/Address/ElectronicMailAddress'))
        )
예제 #38
0
 def __init__(self, md):
     val = md.find('distinfo')
     if val is not None:
         val2 = val.find('stdorder')
         if val2 is not None:
             self.stdorder = {'digform': []}
             for link in val2.findall('digform'):
                 digform = {}
                 digform['name'] = util.testXMLValue(
                     link.find('digtinfo/formname'))
                 digform['url'] = util.testXMLValue(
                     link.find(
                         'digtopt/onlinopt/computer/networka/networkr/'))
                 self.stdorder['digform'].append(digform)
예제 #39
0
파일: wml.py 프로젝트: b-cube/pipeline-demo
    def parse_location(self,xml=None):
        if xml is not None:
            try:
                self._root = etree.parse(xml)
            except:
                self._root = xml

        # try:
        xml_dict = _xml_to_dict(self._root)
        geogs = self._findall('geogLocation')
        self.geo_coords = list()
        self.srs = list()
        for g in geogs:
            self.geo_coords.append((testXMLValue(g.find(ns(self._ns) + 'longitude')),testXMLValue(g.find(ns(self._ns) + 'latitude'))))
            self.srs.append(g.attrib.get('srs'))

        locsite = self._findall('localSiteXY')
        self.local_sites = list()
        self.notes = list()
        self.projections = list()
        for ls in locsite:
            z = testXMLValue(ls.find(ns(self._ns) + 'Z'))
            if z is not None:
                self.local_sites.append((testXMLValue(ls.find(ns(self._ns) + 'X')),testXMLValue(ls.find(ns(self._ns) + 'Y')),z))
            else:
                self.local_sites.append((testXMLValue(ls.find(ns(self._ns) + 'X')),testXMLValue(ls.find(ns(self._ns) + 'Y')),'0'))

            self.notes.append([testXMLValue(note) for note in ls.findall(ns(self._ns) + 'note')])
            self.projections.append(ls.attrib.get('projectionInformation'))
예제 #40
0
파일: iso.py 프로젝트: b-cube/pipeline-demo
 def __init__(self, md=None):
     if md is None:
         self.minx = None
         self.maxx = None
         self.miny = None
         self.maxy = None
     else:
         val = md.find(util.nspath_eval('gmd:westBoundLongitude/gco:Decimal', namespaces))
         self.minx = util.testXMLValue(val)
         val = md.find(util.nspath_eval('gmd:eastBoundLongitude/gco:Decimal', namespaces))
         self.maxx = util.testXMLValue(val)
         val = md.find(util.nspath_eval('gmd:southBoundLatitude/gco:Decimal', namespaces))
         self.miny = util.testXMLValue(val)
         val = md.find(util.nspath_eval('gmd:northBoundLatitude/gco:Decimal', namespaces))
         self.maxy = util.testXMLValue(val)
예제 #41
0
    def __init__(self, element):
        super(TimeRange, self).__init__(element)
        # Elements
        self.uom = get_uom(element.find(nspv("swe20:uom")))

        try:
            self.constraint = AllowedTimes(
                element.find(nspv("swe20:constraint/swe20:AllowedTimes"))
            )  # AllowedTimes, min=0, max=1
        except:
            self.constraint = None

        # Attributes
        self.localFrame = testXMLAttribute(element,
                                           "localFrame")  # anyURI, optional
        try:
            self.referenceTime = parser.parse(
                testXMLAttribute(element,
                                 "referenceTime"))  # dateTime, optional
        except (AttributeError, ValueError):
            self.referenceTime = None

        values = make_pair(testXMLValue(element.find(
            nspv("swe20:value"))))  # TimePosition, min=0, max=1
        self.value = [
            get_time(t, self.referenceTime, self.uom) for t in values
        ]
예제 #42
0
    def __init__(self, md=None):
        if md is None:
            self.boundingBox = None
            self.boundingPolygon = None
            self.description_code = None
        else:
            self.boundingBox = None
            self.boundingPolygon = None

            if md is not None:
                bboxElement = md.find(
                    util.nspath_eval('gmd:EX_GeographicBoundingBox',
                                     namespaces))
                if bboxElement is not None:
                    self.boundingBox = EX_GeographicBoundingBox(bboxElement)

                polygonElement = md.find(
                    util.nspath_eval('gmd:EX_BoundingPolygon', namespaces))
                if polygonElement is not None:
                    self.boundingPolygon = EX_GeographicBoundingPolygon(
                        polygonElement)

                val = md.find(
                    util.nspath_eval(
                        'gmd:EX_GeographicDescription/gmd:geographicIdentifier/gmd:MD_Identifier/gmd:code/gco:CharacterString',
                        namespaces))
                self.description_code = util.testXMLValue(val)
예제 #43
0
    def __init__(self, md):
        val = md.find('bounding/westbc')
        self.westbc = util.testXMLValue(val)

        val = md.find('bounding/eastbc')
        self.eastbc = util.testXMLValue(val)
       
        val = md.find('bounding/northbc')
        self.northbc = util.testXMLValue(val)

        val = md.find('bounding/southbc')
        self.southbc = util.testXMLValue(val)

        if (self.southbc is not None and self.northbc is not None and
        self.eastbc is not None and self.westbc is not None):
            self.bbox = Bbox(self)
예제 #44
0
    def __init__(self, md):
        self.address = []
        for el in md.findall(util.nspath_eval('dif:Address', namespaces)):
            self.address.append(util.testXMLValue(el))

        val = md.find(util.nspath_eval('dif:City', namespaces))
        self.city = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Province_or_State', namespaces))
        self.province_or_state = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Postal_Code', namespaces))
        self.postal_code = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Country', namespaces))
        self.country = util.testXMLValue(val)
예제 #45
0
파일: wml.py 프로젝트: b-cube/pipeline-demo
 def parse_value(self):
     try:
         self.value = testXMLValue(self._root)
         d = self._root.attrib
         self.qualifiers = d.get('qualifiers')
         self.censor_code = d.get('censorCode')
         self.date_time = parser.parse(d.get('dateTime')) if d.get('dateTime') is not None else None
         self.time_offset = d.get('timeOffset')
         self.date_time_utc = parser.parse(d.get('dateTimeUTC')) if d.get('dateTimeUTC') is not None else None
         self.method_id = d.get('methodID')
         self.source_id = d.get('sourceID')
         self.accuracy_std_dev = d.get('accuracyStdDev')
         self.sample_id = d.get('sampleID')
         self.method_code = d.get('methodCode')
         self.source_code = d.get('sourceCode')
         self.lab_sample_code = d.get('lab_sample_code')
         self.offset_value = d.get('offsetValue')
         self.offset_type_id = d.get('offsetTypeID')
         self.offset_type_code = d.get('offsetTypeCode')
         self.coded_vocabulary = d.get('codedVocabulary')
         self.coded_vocabulary_term = d.get('codedVocabularyTerm')
         self.quality_control_level = d.get('qualityControlLevel')
         self.metadata_time = d.get('metadataTime')
         self.oid = d.get('oid')
     except:
         raise
예제 #46
0
    def __init__(self, md):
        val = md.find('bounding/westbc')
        self.westbc = util.testXMLValue(val)

        val = md.find('bounding/eastbc')
        self.eastbc = util.testXMLValue(val)

        val = md.find('bounding/northbc')
        self.northbc = util.testXMLValue(val)

        val = md.find('bounding/southbc')
        self.southbc = util.testXMLValue(val)

        if (self.southbc is not None and self.northbc is not None
                and self.eastbc is not None and self.westbc is not None):
            self.bbox = Bbox(self)
예제 #47
0
 def __init__(self, element):
     super(Boolean, self).__init__(element)
     # Elements
     """
     6.2.1 Boolean
             A Boolean representation of a proptery can take only two values that should be "true/false" or "yes/no".
     """
     value               = get_boolean(testXMLValue(element.find(nspv("swe20:value"))))   # boolean, min=0, max=1
예제 #48
0
 def __init__(self, element):
     super(Matrix, self).__init__(element)
     self.elementCount   = element.find(nspv("swe20:elementCount/swe20:Count"))      # required
     self.elementType    = ElementType(element.find(nspv("swe20:elementType")))      # required
     self.encoding       = AbstractEncoding(element.find(nspv("swe20:encoding")))
     self.values         = testXMLValue(element.find(nspv("swe20:values")))
     self.referenceFrame = testXMLAttribute(element, "referenceFrame")               # anyURI, required
     self.localFrame     = testXMLAttribute(element, "localFrame")                   # anyURI, optional
예제 #49
0
    def __init__(self, md):
        if md is not None:
            val = md.find('current')
            self.current = util.testXMLValue(val)

            val = md.find('timeinfo')
            if val is not None:
                self.timeinfo = Timeinfo(val)
예제 #50
0
파일: iso.py 프로젝트: b-cube/pipeline-demo
    def __init__(self, md=None):
        if md is None:
            self.date = None
            self.type = None
        else:
            val = md.find(util.nspath_eval('gmd:date/gco:Date', namespaces))
            if val is not None:
                self.date = util.testXMLValue(val)
            else:
                val = md.find(util.nspath_eval('gmd:date/gco:DateTime', namespaces))
                if val is not None:
                    self.date = util.testXMLValue(val)
                else:
                    self.date = None

            val = md.find(util.nspath_eval('gmd:dateType/gmd:CI_DateTypeCode', namespaces))
            self.type = _testCodeListValue(val)
예제 #51
0
파일: dif.py 프로젝트: b-cube/pipeline-demo
    def __init__(self, md):
        self.role = []
        for el in md.findall(util.nspath_eval('dif:Role', namespaces)):
            self.role.append(util.testXMLValue(el))

        val = md.find(util.nspath_eval('dif:First_Name', namespaces))
        self.first_name = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Middle_Name', namespaces))
        self.middle_name = util.testXMLValue(val)

        val = md.find(util.nspath_eval('dif:Last_Name', namespaces))
        self.last_name = util.testXMLValue(val)

        self.email = []
        for el in md.findall(util.nspath_eval('dif:Email', namespaces)):
            self.email.append(util.testXMLValue(el))

        self.phone = []
        for el in md.findall(util.nspath_eval('dif:Phone', namespaces)):
            self.phone.append(util.testXMLValue(el))

        self.fax = []
        for el in md.findall(util.nspath_eval('dif:Fax', namespaces)):
            self.fax.append(util.testXMLValue(el))

        val = md.find(util.nspath_eval('dif:Contact_Address', namespaces))
        self.contact_address = Contact_Address(val)