本文整理汇总了Python中owslib.namespaces.Namespaces类的典型用法代码示例。如果您正苦于以下问题:Python Namespaces类的具体用法?Python Namespaces怎么用?Python Namespaces使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Namespaces类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: patch_well_known_namespaces
def patch_well_known_namespaces(etree_module):
from owslib.namespaces import Namespaces
ns = Namespaces()
"""Monkey patches the etree module to add some well-known namespaces."""
etree_module._namespace_map.update(ns.get_namespaces())
示例2: patch_well_known_namespaces
def patch_well_known_namespaces(etree_module):
from owslib.namespaces import Namespaces
ns = Namespaces()
"""Monkey patches the etree module to add some well-known namespaces."""
for k,v in ns.get_namespaces().iteritems():
etree_module.register_namespace(k, v)
示例3: get_namespaces
def get_namespaces():
"""
Returns specified namespaces using owslib Namespaces function.
"""
n = Namespaces()
ns = n.get_namespaces(
["gco", "gmd", "gml", "gml32", "gmx", "gts", "srv", "xlink", "dc"])
return ns
示例4: get_namespaces_io100
def get_namespaces_io100():
n = Namespaces()
ns = n.get_namespaces(["ogc","swes","sml","xlink","xsi"])
ns["ows"] = n.get_namespace("ows110")
ns["sos"] = n.get_namespace("sos20")
ns["gml"] = n.get_namespace("gml32")
ns["om"] = n.get_namespace("om20")
ns['swe'] = 'http://www.opengis.net/swe/2.0'
ns["sams"] = "http://www.opengis.net/samplingSpatial/2.0"
ns["sf"] = "http://www.opengis.net/sampling/2.0"
return ns
示例5: patch_well_known_namespaces
def patch_well_known_namespaces(etree_module):
import warnings
from owslib.namespaces import Namespaces
ns = Namespaces()
"""Monkey patches the etree module to add some well-known namespaces."""
try:
register_namespace = etree_module.register_namespace
except AttributeError:
try:
etree_module._namespace_map
def register_namespace(prefix, uri):
etree_module._namespace_map[uri] = prefix
except AttributeError:
def register_namespace(prefix, uri):
pass
warnings.warn("Only 'lxml.etree' >= 2.3 and 'xml.etree.ElementTree' >= 1.3 are fully supported!")
for k, v in ns.get_namespaces().iteritems():
register_namespace(k, v)
示例6: add_namespaces
def add_namespaces(root, ns_keys):
if isinstance(ns_keys, six.string_types):
ns_keys = [ns_keys]
namespaces = Namespaces()
ns_keys = [(x, namespaces.get_namespace(x)) for x in ns_keys]
if etree.__name__ != 'lxml.etree':
# We can just add more namespaces when not using lxml.
# We can't re-add an existing namespaces. Get a list of current
# namespaces in use
existing_namespaces = set()
for elem in root.getiterator():
if elem.tag[0] == "{":
uri, tag = elem.tag[1:].split("}")
existing_namespaces.add(namespaces.get_namespace_from_url(uri))
for key, link in ns_keys:
if link is not None and key not in existing_namespaces:
root.set("xmlns:%s" % key, link)
return root
else:
# lxml does not support setting xmlns attributes
# Update the elements nsmap with new namespaces
new_map = root.nsmap
for key, link in ns_keys:
if link is not None:
new_map[key] = link
# Recreate the root element with updated nsmap
new_root = etree.Element(root.tag, nsmap=new_map)
# Carry over attributes
for a, v in list(root.items()):
new_root.set(a, v)
# Carry over children
for child in root:
new_root.append(deepcopy(child))
return new_root
示例7: Namespaces
from __future__ import absolute_import, division, print_function
from owslib.namespaces import Namespaces
from pyoos.utils.etree import ElementType, etree
ns = Namespaces()
SML_NS = ns.get_versioned_namespace("sml", "1.0.1")
SWE_NS = [ns.get_versioned_namespace("swe", "1.0.1")]
class IoosDescribeSensor(object):
def __new__(cls, element):
if isinstance(element, ElementType):
root = element
else:
root = etree.fromstring(element)
sml_str = ".//{{{0}}}identifier/{{{0}}}Term[@definition='http://mmisw.org/ont/ioos/definition/%s']".format(
SML_NS
)
if hasattr(root, "getroot"):
root = root.getroot()
# Circular dependencies are bad. consider a reorganization
# find the the proper type for the DescribeSensor.
from pyoos.parsers.ioos.one.describe_sensor import (
NetworkDS,
StationDS,
SensorDS,
示例8: get_namespaces
def get_namespaces():
ns = Namespaces()
return ns.get_namespaces(["swe20"])
示例9: get_namespaces
def get_namespaces():
n = Namespaces()
ns = n.get_namespaces(["gm03"])
ns[None] = n.get_namespace("gm03")
return ns
示例10: Common
"""
API for OGC Web Services Common (OWS) constructs and metadata.
OWS Common: http://www.opengeospatial.org/standards/common
Currently supports version 1.1.0 (06-121r3).
"""
from __future__ import absolute_import, division, print_function
from owslib.etree import etree
from owslib import crs, util
from owslib.namespaces import Namespaces
n = Namespaces()
OWS_NAMESPACE_1_0_0 = n.get_namespace("ows")
OWS_NAMESPACE_1_1_0 = n.get_namespace("ows110")
OWS_NAMESPACE_2_0 = n.get_namespace("ows200")
XSI_NAMESPACE = n.get_namespace("xsi")
XLINK_NAMESPACE = n.get_namespace("xlink")
DEFAULT_OWS_NAMESPACE = OWS_NAMESPACE_1_1_0 # Use this as default for OWSCommon objects
class OwsCommon(object):
"""Initialize OWS Common object"""
def __init__(self, version):
self.version = version
示例11: get_namespaces
def get_namespaces():
n = Namespaces()
ns = n.get_namespaces("dif")
ns[None] = n.get_namespace("dif")
return ns
示例12: get_namespaces
def get_namespaces():
n = Namespaces()
ns = n.get_namespaces(["dif","fes","gml","ogc","xs","xsi"])
ns[None] = n.get_namespace("ogc")
return ns
示例13: get_namespaces
def get_namespaces():
n = Namespaces()
return n.get_namespaces(["sml101", "gml", "xlink", "swe101"])
示例14: import
import warnings
import six
from owslib.etree import etree
from owslib.util import (openURL, ServiceException, testXMLValue,
extract_xml_list, xmltag_split, OrderedDict, nspath,
bind_url)
from owslib.util import nspath
from owslib.fgdc import Metadata
from owslib.iso import MD_Metadata
from owslib.crs import Crs
from owslib.namespaces import Namespaces
from owslib.map.common import WMSCapabilitiesReader
from owslib.util import log
n = Namespaces()
WMS_NAMESPACE = n.get_namespace("wms")
OGC_NAMESPACE = n.get_namespace('ogc')
class WebMapService_1_3_0(object):
def __getitem__(self, name):
''' check contents dictionary to allow dict
like access to service layers
'''
if name in self.__getattribute__('contents'):
return self.__getattribute__('contents')[name]
else:
raise KeyError("No content named %s" % name)
示例15: get_namespaces
def get_namespaces():
n = Namespaces()
return n.get_namespaces()