def _buildMetadata(self, parse_remote_metadata=False): """set up capabilities metadata objects: """ self.updateSequence = self._capabilities.attrib.get("updateSequence") # ServiceIdentification val = self._capabilities.find( nspath_eval("ows:ServiceIdentification", namespaces)) if val is not None: self.identification = ServiceIdentification( val, self.owscommon.namespace) # ServiceProvider val = self._capabilities.find( nspath_eval("ows:ServiceProvider", namespaces)) if val is not None: self.provider = ServiceProvider(val, self.owscommon.namespace) # ServiceOperations metadata self.operations = [] for elem in self._capabilities.findall( nspath_eval("ows:OperationsMetadata/ows:Operation", namespaces)): self.operations.append( OperationsMetadata(elem, self.owscommon.namespace)) self.constraints = {} for elem in self._capabilities.findall( nspath_eval("ows:OperationsMetadata/ows:Constraint", namespaces)): self.constraints[elem.attrib["name"]] = Constraint( elem, self.owscommon.namespace) self.parameters = {} for elem in self._capabilities.findall( nspath_eval("ows:OperationsMetadata/ows:Parameter", namespaces)): self.parameters[elem.attrib["name"]] = Parameter( elem, self.owscommon.namespace) # FilterCapabilities val = self._capabilities.find( nspath_eval("ogc:Filter_Capabilities", namespaces)) self.filters = FilterCapabilities(val) # serviceContents metadata: our assumption is that services use a top-level # layer as a metadata organizer, nothing more. self.contents = {} features = self._capabilities.findall( nspath_eval("wfs:FeatureTypeList/wfs:FeatureType", namespaces)) if features is not None: for feature in features: cm = ContentMetadata(feature, parse_remote_metadata, headers=self.headers, auth=self.auth) self.contents[cm.id] = cm # exceptions self.exceptions = [ f.text for f in self._capabilities.findall("Capability/Exception/Format") ]
def _buildMetadata(self, parse_remote_metadata=False): '''set up capabilities metadata objects: ''' self.updateSequence = self._capabilities.attrib.get('updateSequence') #serviceIdentification metadata serviceidentelem = self._capabilities.find( nspath('ServiceIdentification')) self.identification = ServiceIdentification(serviceidentelem) #need to add to keywords list from featuretypelist information: featuretypelistelem = self._capabilities.find( nspath('FeatureTypeList', ns=WFS_NAMESPACE)) featuretypeelems = featuretypelistelem.findall( nspath('FeatureType', ns=WFS_NAMESPACE)) for f in featuretypeelems: kwds = f.findall(nspath('Keywords/Keyword', ns=OWS_NAMESPACE)) if kwds is not None: for kwd in kwds[:]: if kwd.text not in self.identification.keywords: self.identification.keywords.append(kwd.text) #TODO: update serviceProvider metadata, miss it out for now serviceproviderelem = self._capabilities.find( nspath('ServiceProvider')) self.provider = ServiceProvider(serviceproviderelem) #serviceOperations metadata self.operations = [] for elem in self._capabilities.find(nspath('OperationsMetadata'))[:]: if elem.tag != nspath('ExtendedCapabilities'): self.operations.append(OperationsMetadata(elem)) self.constraints = {} for elem in self._capabilities.findall( nspath('OperationsMetadata/Constraint', ns=WFS_NAMESPACE)): self.constraints[elem.attrib['name']] = Constraint( elem, self.owscommon.namespace) self.parameters = {} for elem in self._capabilities.findall( nspath('OperationsMetadata/Parameter', ns=WFS_NAMESPACE)): self.parameters[elem.attrib['name']] = Parameter( elem, self.owscommon.namespace) #serviceContents metadata: our assumption is that services use a top-level #layer as a metadata organizer, nothing more. self.contents = {} featuretypelist = self._capabilities.find( nspath('FeatureTypeList', ns=WFS_NAMESPACE)) features = self._capabilities.findall( nspath('FeatureTypeList/FeatureType', ns=WFS_NAMESPACE)) for feature in features: cm = ContentMetadata(feature, featuretypelist, parse_remote_metadata) self.contents[cm.id] = cm #exceptions self.exceptions = [f.text for f \ in self._capabilities.findall('Capability/Exception/Format')]
def __init__(self, url, xml, cookies, auth=None, timeout=30, headers=None): super(WebCoverageService_2_0_0, self).__init__(auth=auth, timeout=timeout, headers=headers) self.version = "2.0.0" self.url = url self.cookies = cookies self.timeout = timeout self.ows_common = OwsCommon(version="2.0.0") # initialize from saved capability document or access the server reader = WCSCapabilitiesReader(self.version, self.cookies, self.auth, headers=self.headers) if xml: self._capabilities = reader.readString(xml) else: self._capabilities = reader.read(self.url, self.timeout) # check for exceptions se = self._capabilities.find("ServiceException") if se is not None: err_message = str(se.text).strip() raise ServiceException(err_message, xml) # serviceIdentification metadata subelem = self._capabilities.find(ns("ServiceIdentification")) self.identification = ServiceIdentification( subelem, namespace=self.ows_common.namespace) # serviceProvider metadata serviceproviderelem = self._capabilities.find(ns("ServiceProvider")) self.provider = ServiceProvider(serviceproviderelem, namespace=self.ows_common.namespace) # serviceOperations metadata self.operations = [] for elem in self._capabilities.find(ns("OperationsMetadata"))[:]: if elem.tag != ns("ExtendedCapabilities"): self.operations.append( OperationsMetadata(elem, namespace=self.ows_common.namespace)) # serviceContents metadata self.contents = {} for elem in self._capabilities.findall( nsWCS2("Contents/") + nsWCS2("CoverageSummary")): cm = ContentMetadata(elem, self) self.contents[cm.id] = cm # exceptions self.exceptions = [ f.text for f in self._capabilities.findall("Capability/Exception/Format") ]
def __init__(self, url, xml, cookies, auth=None): super(WebCoverageService_2_0_1, self).__init__(auth=auth) self.version = '2.0.1' self.url = url self.cookies = cookies self.ows_common = OwsCommon(version='2.0.1') # initialize from saved capability document or access the server reader = WCSCapabilitiesReader(self.version, self.cookies, self.auth) if xml: self._capabilities = reader.readString(xml) else: self._capabilities = reader.read(self.url) # check for exceptions se = self._capabilities.find('ServiceException') if se is not None: err_message = str(se.text).strip() raise ServiceException(err_message, xml) #serviceIdentification metadata subelem = self._capabilities.find(ns('ServiceIdentification')) self.identification = ServiceIdentification( subelem, namespace=self.ows_common.namespace) #serviceProvider metadata serviceproviderelem = self._capabilities.find(ns('ServiceProvider')) self.provider = ServiceProvider(serviceproviderelem, namespace=self.ows_common.namespace) #serviceOperations metadata self.operations = [] for elem in self._capabilities.find(ns('OperationsMetadata'))[:]: if elem.tag != ns('ExtendedCapabilities'): self.operations.append( OperationsMetadata(elem, namespace=self.ows_common.namespace)) #serviceContents metadata self.contents = {} for elem in self._capabilities.findall( nsWCS2('Contents/') + nsWCS2('CoverageSummary')): cm = ContentMetadata(elem, self) self.contents[cm.id] = cm #exceptions self.exceptions = [f.text for f \ in self._capabilities.findall('Capability/Exception/Format')]