コード例 #1
0
ファイル: wfs110.py プロジェクト: tomkralidis/OWSLib
 def __init__(
     self,
     url,
     version,
     xml=None,
     parse_remote_metadata=False,
     timeout=30,
     headers=None,
     username=None,
     password=None,
     auth=None,
 ):
     """Initialize."""
     if auth:
         if username:
             auth.username = username
         if password:
             auth.password = password
     else:
         auth = Authentication(username, password)
     super(WebFeatureService_1_1_0, self).__init__(auth)
     self.url = url
     self.version = version
     self.headers = headers
     self.timeout = timeout
     self._capabilities = None
     self.owscommon = OwsCommon("1.0.0")
     reader = WFSCapabilitiesReader(self.version,
                                    headers=self.headers,
                                    auth=self.auth)
     if xml:
         self._capabilities = reader.readString(xml)
     else:
         self._capabilities = reader.read(self.url, self.timeout)
     self._buildMetadata(parse_remote_metadata)
コード例 #2
0
ファイル: wcs200.py プロジェクト: geopython/OWSLib
    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")
        ]
コード例 #3
0
ファイル: wcs201.py プロジェクト: yalaudah/OWSLib
    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')]