/usr/lib/python2.7/dist-packages/owslib/namespaces.py is in python-owslib 0.10.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | from __future__ import (absolute_import, division, print_function)
import six
class Namespaces(object):
"""
Class for holding and maniputlating a dictionary containing the various namespaces for
each standard.
"""
namespace_dict = {
'atom' : 'http://www.w3.org/2005/Atom',
'csw' : 'http://www.opengis.net/cat/csw/2.0.2',
'dc' : 'http://purl.org/dc/elements/1.1/',
'dct' : 'http://purl.org/dc/terms/',
'dif' : 'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/',
'draw' : 'gov.usgs.cida.gdp.draw',
'fes' : 'http://www.opengis.net/fes/2.0',
'fgdc' : 'http://www.opengis.net/cat/csw/csdgm',
'gco' : 'http://www.isotc211.org/2005/gco',
'gm03' : 'http://www.interlis.ch/INTERLIS2.3',
'gmd' : 'http://www.isotc211.org/2005/gmd',
'gmi' : 'http://www.isotc211.org/2005/gmi',
'gml' : 'http://www.opengis.net/gml',
'gml311': 'http://www.opengis.net/gml',
'gml32' : 'http://www.opengis.net/gml/3.2',
'gmx' : 'http://www.isotc211.org/2005/gmx',
'gts' : 'http://www.isotc211.org/2005/gts',
'ogc' : 'http://www.opengis.net/ogc',
'om' : 'http://www.opengis.net/om/1.0',
'om10' : 'http://www.opengis.net/om/1.0',
'om100' : 'http://www.opengis.net/om/1.0',
'om20' : 'http://www.opengis.net/om/2.0',
'ows' : 'http://www.opengis.net/ows',
'ows100': 'http://www.opengis.net/ows',
'ows110': 'http://www.opengis.net/ows/1.1',
'ows200': 'http://www.opengis.net/ows/2.0',
'rim' : 'urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0',
'rdf' : 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'sa' : 'http://www.opengis.net/sampling/1.0',
'sml' : 'http://www.opengis.net/sensorML/1.0.1',
'sml101': 'http://www.opengis.net/sensorML/1.0.1',
'sos' : 'http://www.opengis.net/sos/1.0',
'sos20' : 'http://www.opengis.net/sos/2.0',
'srv' : 'http://www.isotc211.org/2005/srv',
'swe' : 'http://www.opengis.net/swe/1.0.1',
'swe10' : 'http://www.opengis.net/swe/1.0',
'swe101': 'http://www.opengis.net/swe/1.0.1',
'swe20' : 'http://www.opengis.net/swe/2.0',
'swes' : 'http://www.opengis.net/swes/2.0',
'tml' : 'ttp://www.opengis.net/tml',
'wfs' : 'http://www.opengis.net/wfs',
'wfs20' : 'http://www.opengis.net/wfs/2.0',
'wcs' : 'http://www.opengis.net/wcs',
'wps' : 'http://www.opengis.net/wps/1.0.0',
'wps100': 'http://www.opengis.net/wps/1.0.0',
'xlink' : 'http://www.w3.org/1999/xlink',
'xs' : 'http://www.w3.org/2001/XMLSchema',
'xs2' : 'http://www.w3.org/XML/Schema',
'xsi' : 'http://www.w3.org/2001/XMLSchema-instance'
}
def get_namespace(self, key):
"""
Retrieves a namespace from the dictionary
Example:
--------
>>> from owslib.namespaces import Namespaces
>>> ns = Namespaces()
>>> ns.get_namespace('csw')
'http://www.opengis.net/cat/csw/2.0.2'
>>> ns.get_namespace('wfs20')
'http://www.opengis.net/wfs/2.0'
"""
retval = None
if key in self.namespace_dict:
retval = self.namespace_dict[key]
return retval
def get_versioned_namespace(self, key, ver=None):
"""
Retrieves a namespace from the dictionary with a specific version number
Example:
--------
>>> from owslib.namespaces import Namespaces
>>> ns = Namespaces()
>>> ns.get_versioned_namespace('ows')
'http://www.opengis.net/ows'
>>> ns.get_versioned_namespace('ows','1.1.0')
'http://www.opengis.net/ows/1.1'
"""
if ver is None:
return self.get_namespace(key)
version = ''
# Strip the decimals out of the passed in version
for s in ver.split('.'):
version += s
key += version
retval = None
if key in self.namespace_dict:
retval = self.namespace_dict[key]
return retval
def get_namespaces(self, keys=None):
"""
Retrieves a dict of namespaces from the namespace mapping
Parameters
----------
- keys: List of keys query and return
Example:
--------
>>> ns = Namespaces()
>>> x = ns.get_namespaces(['csw','gmd'])
>>> x == {'csw': 'http://www.opengis.net/cat/csw/2.0.2', 'gmd': 'http://www.isotc211.org/2005/gmd'}
True
>>> x = ns.get_namespaces('csw')
>>> x == {'csw': 'http://www.opengis.net/cat/csw/2.0.2'}
True
>>> ns.get_namespaces()
{...}
"""
# If we aren't looking for any namespaces in particular return the whole dict
if keys is None or len(keys) == 0:
return self.namespace_dict
if isinstance(keys, six.string_types):
return { keys: self.get_namespace(keys) }
retval = {}
for key in keys:
retval[key] = self.get_namespace(key)
return retval
def get_namespace_from_url(self, url):
for k, v in self.namespace_dict.items():
if v == url:
return k
return None
|