• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geopython / OWSLib / 3663624217

pending completion
3663624217

Pull #851

github

GitHub
Merge 75b79762c into 13b1443f7
Pull Request #851: Adding Python 3.10 in CI

7453 of 12701 relevant lines covered (58.68%)

0.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/owslib/namespaces.py
1
class Namespaces(object):
1✔
2
    """
3
        Class for holding and maniputlating a dictionary containing the various namespaces for
4
        each standard.
5
    """
6

7
    namespace_dict = {
1✔
8
        'atom': 'http://www.w3.org/2005/Atom',
9
        'csw': 'http://www.opengis.net/cat/csw/2.0.2',
10
        'csw30': 'http://www.opengis.net/cat/csw/3.0',
11
        'dc': 'http://purl.org/dc/elements/1.1/',
12
        'dct': 'http://purl.org/dc/terms/',
13
        'dif': 'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/',
14
        'draw': 'gov.usgs.cida.gdp.draw',
15
        'fes': 'http://www.opengis.net/fes/2.0',
16
        'fgdc': 'http://www.opengis.net/cat/csw/csdgm',
17
        'gco': 'http://www.isotc211.org/2005/gco',
18
        'gfc': 'http://www.isotc211.org/2005/gfc',
19
        'gm03': 'http://www.interlis.ch/INTERLIS2.3',
20
        'gmd': 'http://www.isotc211.org/2005/gmd',
21
        'gmi': 'http://www.isotc211.org/2005/gmi',
22
        'gml': 'http://www.opengis.net/gml',
23
        'gml311': 'http://www.opengis.net/gml',
24
        'gml32': 'http://www.opengis.net/gml/3.2',
25
        'gmx': 'http://www.isotc211.org/2005/gmx',
26
        'gts': 'http://www.isotc211.org/2005/gts',
27
        'ogc': 'http://www.opengis.net/ogc',
28
        'om': 'http://www.opengis.net/om/1.0',
29
        'om10': 'http://www.opengis.net/om/1.0',
30
        'om100': 'http://www.opengis.net/om/1.0',
31
        'om20': 'http://www.opengis.net/om/2.0',
32
        'ows': 'http://www.opengis.net/ows',
33
        'ows100': 'http://www.opengis.net/ows',
34
        'ows110': 'http://www.opengis.net/ows/1.1',
35
        'ows200': 'http://www.opengis.net/ows/2.0',
36
        'rim': 'urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0',
37
        'rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
38
        'sa': 'http://www.opengis.net/sampling/1.0',
39
        'sml': 'http://www.opengis.net/sensorML/1.0.1',
40
        'sml101': 'http://www.opengis.net/sensorML/1.0.1',
41
        'sos': 'http://www.opengis.net/sos/1.0',
42
        'sos20': 'http://www.opengis.net/sos/2.0',
43
        'srv': 'http://www.isotc211.org/2005/srv',
44
        'swe': 'http://www.opengis.net/swe/1.0.1',
45
        'swe10': 'http://www.opengis.net/swe/1.0',
46
        'swe101': 'http://www.opengis.net/swe/1.0.1',
47
        'swe20': 'http://www.opengis.net/swe/2.0',
48
        'swes': 'http://www.opengis.net/swes/2.0',
49
        'tml': 'ttp://www.opengis.net/tml',
50
        'wfs': 'http://www.opengis.net/wfs',
51
        'wfs20': 'http://www.opengis.net/wfs/2.0',
52
        'wcs': 'http://www.opengis.net/wcs',
53
        'wms': 'http://www.opengis.net/wms',
54
        'wps': 'http://www.opengis.net/wps/1.0.0',
55
        'wps100': 'http://www.opengis.net/wps/1.0.0',
56
        'xlink': 'http://www.w3.org/1999/xlink',
57
        'xs': 'http://www.w3.org/2001/XMLSchema',
58
        'xs2': 'http://www.w3.org/XML/Schema',
59
        'xsi': 'http://www.w3.org/2001/XMLSchema-instance',
60
        'wml2': 'http://www.opengis.net/waterml/2.0'
61
    }
62

63
    def get_namespace(self, key):
1✔
64
        """
65
            Retrieves a namespace from the dictionary
66

67
            Example:
68
            --------
69

70
            >>> from owslib.namespaces import Namespaces
71
            >>> ns = Namespaces()
72
            >>> ns.get_namespace('csw')
73
            'http://www.opengis.net/cat/csw/2.0.2'
74
            >>> ns.get_namespace('wfs20')
75
            'http://www.opengis.net/wfs/2.0'
76
        """
77
        retval = None
1✔
78
        if key in self.namespace_dict:
1✔
79
            retval = self.namespace_dict[key]
1✔
80
        return retval
1✔
81

82
    def get_versioned_namespace(self, key, ver=None):
1✔
83
        """
84
            Retrieves a namespace from the dictionary with a specific version number
85

86
            Example:
87
            --------
88

89
            >>> from owslib.namespaces import Namespaces
90
            >>> ns = Namespaces()
91
            >>> ns.get_versioned_namespace('ows')
92
            'http://www.opengis.net/ows'
93
            >>> ns.get_versioned_namespace('ows','1.1.0')
94
            'http://www.opengis.net/ows/1.1'
95
        """
96

97
        if ver is None:
1✔
98
            return self.get_namespace(key)
1✔
99

100
        version = ''
1✔
101
        # Strip the decimals out of the passed in version
102
        for s in ver.split('.'):
1✔
103
            version += s
1✔
104

105
        key += version
1✔
106

107
        retval = None
1✔
108
        if key in self.namespace_dict:
1✔
109
            retval = self.namespace_dict[key]
1✔
110

111
        return retval
1✔
112

113
    def get_namespaces(self, keys=None):
1✔
114
        """
115
            Retrieves a dict of namespaces from the namespace mapping
116

117
            Parameters
118
            ----------
119
            - keys: List of keys query and return
120

121
            Example:
122
            --------
123
            >>> ns = Namespaces()
124
            >>> x = ns.get_namespaces(['csw','gmd'])
125
            >>> x == {'csw': 'http://www.opengis.net/cat/csw/2.0.2', 'gmd': 'http://www.isotc211.org/2005/gmd'}
126
            True
127
            >>> x = ns.get_namespaces('csw')
128
            >>> x == {'csw': 'http://www.opengis.net/cat/csw/2.0.2'}
129
            True
130
            >>> ns.get_namespaces()
131
            {...}
132
        """
133
        # If we aren't looking for any namespaces in particular return the whole dict
134
        if keys is None or len(keys) == 0:
1✔
135
            return self.namespace_dict
1✔
136

137
        if isinstance(keys, str):
1✔
138
            return {keys: self.get_namespace(keys)}
1✔
139

140
        retval = {}
1✔
141
        for key in keys:
1✔
142
            retval[key] = self.get_namespace(key)
1✔
143

144
        return retval
1✔
145

146
    def get_namespace_from_url(self, url):
1✔
147
        for k, v in list(self.namespace_dict.items()):
×
148
            if v == url:
×
149
                return k
×
150
        return None
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc