Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def parse_owc_content(content_node):
mimetype = util.testXMLAttribute(content_node, 'type')
url = util.testXMLAttribute(content_node, 'href')
title = util.testXMLAttribute(content_node, 'title')
child_elem = None
if len(list(content_node)) > 0:
child_elem = element_to_string(
list(content_node)[0],False)
content_dict = {
"type": mimetype,
"url": url,
"content": str(child_elem),
"title": title
}
return content_dict
#
#
# ..
#
# raster
# Default Raster
# A sample style that draws a
#
#
offering_nodes = entry_node.findall(util.nspath_eval('owc:offering', ns))
offerings = []
for offering_node in offering_nodes:
offering_code = util.testXMLAttribute(offering_node, 'code')
operations = []
contents = []
styles = []
operation_nodes = offering_node.findall(
util.nspath_eval('owc:operation', ns))
for op_val in operation_nodes:
operations_code = util.testXMLAttribute(op_val, 'code')
http_method = util.testXMLAttribute(op_val, 'method')
mimetype = util.testXMLAttribute(op_val, 'type')
request_url = util.testXMLAttribute(op_val, 'href')
req_content_val = val.find(util.nspath_eval('owc:request', ns))
req_content = None
if req_content_val is not None:
request_content = parse_owc_content(req_content_val)
# TODO no example for result/response
self.keywords = []
for i in md.findall(util.nspath_eval('gmd:descriptiveKeywords', namespaces)):
mdkw = {}
mdkw['type'] = _testCodeListValue(i.find(util.nspath_eval('gmd:MD_Keywords/gmd:type/gmd:MD_KeywordTypeCode', namespaces)))
mdkw['thesaurus'] = {}
val = i.find(util.nspath_eval('gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:title/gco:CharacterString', namespaces))
mdkw['thesaurus']['title'] = util.testXMLValue(val)
val = i.find(util.nspath_eval('gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:date/gmd:CI_Date/gmd:date/gco:Date', namespaces))
mdkw['thesaurus']['date'] = util.testXMLValue(val)
val = i.find(util.nspath_eval('gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:date/gmd:CI_Date/gmd:dateType/gmd:CI_DateTypeCode', namespaces))
mdkw['thesaurus']['datetype'] = util.testXMLAttribute(val, 'codeListValue')
mdkw['keywords'] = []
for k in i.findall(util.nspath_eval('gmd:MD_Keywords/gmd:keyword', namespaces)):
val = k.find(util.nspath_eval('gco:CharacterString', namespaces))
if val is not None:
val2 = util.testXMLValue(val)
if val2 is not None:
mdkw['keywords'].append(val2)
self.keywords.append(mdkw)
self.keywords2 = []
for mdkw in md.findall(util.nspath_eval('gmd:descriptiveKeywords/gmd:MD_Keywords', namespaces)):
self.keywords2.append(MD_Keywords(mdkw))
def __init__(self, element):
super(TVPMeasurementMetadata, self).__init__(element)
self.uom = testXMLAttribute(element.find(nspv(
"wml2:uom")), "code")
self.interpolationType = testXMLAttribute(element.find(nspv(
"wml2:interpolationType")), nspv("xlink:href"))
self.censoredReason = testXMLAttribute(element.find(nspv(
"wml2:censoredReason")), "xlink:href")
accuracy = testXMLValue(element.find(nspv("wml2:accuracy")))
if accuracy is not None:
self.accuracy = Quantity(element)
def __init__(self, element):
# TODO: This only supports the sml:contact/sml:ResponsibleParty elements, but there are numerous ways to store
# contact information here.
self.role = testXMLAttribute(element, nsp("xlink:role"))
self.href = testXMLAttribute(element, nsp("xlink:href"))
self.organization = testXMLValue(element.find(nsp('sml:ResponsibleParty/sml:organizationName')))
self.phone = testXMLValue(element.find(nsp('sml:ResponsibleParty/sml:contactInfo/sml:phone/sml:voice')))
self.address = testXMLValue(element.find(nsp('sml:ResponsibleParty/sml:contactInfo/sml:address/sml:deliveryPoint')))
self.city = testXMLValue(element.find(nsp('sml:ResponsibleParty/sml:contactInfo/sml:address/sml:city')))
self.region = testXMLValue(element.find(nsp('sml:ResponsibleParty/sml:contactInfo/sml:address/sml:administrativeArea')))
self.postcode = testXMLValue(element.find(nsp('sml:ResponsibleParty/sml:contactInfo/sml:address/sml:postalCode')))
self.country = testXMLValue(element.find(nsp('sml:ResponsibleParty/sml:contactInfo/sml:address/sml:country')))
self.email = testXMLValue(element.find(nsp('sml:ResponsibleParty/sml:contactInfo/sml:address/sml:electronicMailAddress')))
self.url = testXMLAttribute(element.find(nsp('sml:ResponsibleParty/sml:contactInfo/sml:onlineResource')), nsp("xlink:href"))
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, TypeError):
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]
def get_uom(element):
uom = testXMLAttribute(element, "code")
if uom is None:
uom = testXMLAttribute(element, nspv("xlink:href"))
return uom
def __init__(self, element):
self.arcrole = testXMLAttribute(element, nsp("xlink:arcrole"))
self.url = testXMLAttribute(element, nsp("xlink:href"))
self.documents = [Document(d) for d in element.findall(nsp("sml:Document"))]
def __init__(self, element):
self.arcrole = testXMLAttribute(element, nsp("xlink:arcrole"))
self.url = testXMLAttribute(element, nsp("xlink:href"))
self.documents = [Document(d) for d in element.findall(nsp("sml:Document"))]
def __init__(self, element):
self.tokenSeparator = testXMLAttribute(element[-1], "tokenSeparator") # string, required
self.blockSeparator = testXMLAttribute(element[-1], "blockSeparator") # string, required
self.decimalSeparator = testXMLAttribute(element[-1], "decimalSeparator") or "." # string, optional, default="."
self.collapseWhiteSpaces = get_boolean(testXMLAttribute(element[-1], "collapseWhiteSpaces")) or True # boolean, optional, default=True