本文整理汇总了Python中suds.sax.splitPrefix函数的典型用法代码示例。如果您正苦于以下问题:Python splitPrefix函数的具体用法?Python splitPrefix怎么用?Python splitPrefix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了splitPrefix函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: qualify
def qualify(ref, resolvers, defns=Namespace.default):
"""
Get a reference that is I{qualified} by namespace.
@param ref: A referenced schema type name.
@type ref: str
@param resolvers: A list of objects to be used to resolve types.
@type resolvers: [L{sax.element.Element},]
@param defns: An optional target namespace used to qualify references
when no prefix is specified.
@type defns: A default namespace I{tuple: (prefix,uri)} used when ref not prefixed.
@return: A qualified reference.
@rtype: (name, namespace-uri)
"""
ns = None
p, n = splitPrefix(ref)
if p is not None:
if not isinstance(resolvers, (list, tuple)):
resolvers = (resolvers,)
for r in resolvers:
resolved = r.resolvePrefix(p)
if resolved[1] is not None:
ns = resolved
break
if ns is None:
raise Exception('prefix (%s) not resolved' % p)
else:
ns = defns
return (n, ns[1])
开发者ID:digidotcom,项目名称:map-idigi,代码行数:28,代码来源:__init__.py
示例2: rename
def rename(self, name):
"""
Rename the element.
@param name: A new name for the element.
@type name: basestring
"""
if name is None:
raise Exception('name (%s) not-valid' % name)
else:
self.prefix, self.name = splitPrefix(name)
开发者ID:EquipmentShare,项目名称:suds-py3,代码行数:10,代码来源:element.py
示例3: __init__
def __init__(self, name, value=None):
"""
@param name: The attribute's name with I{optional} namespace prefix.
@type name: basestring
@param value: The attribute's value
@type value: basestring
"""
self.parent = None
self.prefix, self.name = splitPrefix(name)
self.setValue(value)
开发者ID:farkasgy,项目名称:suds-py3,代码行数:10,代码来源:attribute.py
示例4: __childrenAtPath
def __childrenAtPath(self, parts):
result = []
node = self
last = len(parts)-1
ancestors = parts[:last]
leaf = parts[last]
for name in ancestors:
ns = None
prefix, name = splitPrefix(name)
if prefix is not None:
ns = node.resolvePrefix(prefix)
child = node.getChild(name, ns)
if child is None:
break
else:
node = child
if child is not None:
ns = None
prefix, leaf = splitPrefix(leaf)
if prefix is not None:
ns = node.resolvePrefix(prefix)
result = child.getChildren(leaf)
return result
开发者ID:EquipmentShare,项目名称:suds-py3,代码行数:23,代码来源:element.py
示例5: refitValue
def refitValue(self, a):
"""
Refit (normalize) the attribute's value.
@param a: An attribute.
@type a: L{Attribute}
"""
p, name = splitPrefix(a.getValue())
if p is None:
return
ns = a.resolvePrefix(p)
if self.permit(ns):
u = ns[1]
p = self.prefixes[u]
a.setValue(':'.join((p, name)))
开发者ID:EquipmentShare,项目名称:suds-py3,代码行数:14,代码来源:element.py
示例6: leaf
def leaf(self, parent, parts):
"""
Find the leaf.
@param parts: A list of path parts.
@type parts: [str,..]
@param parent: The leaf's parent.
@type parent: L{xsd.sxbase.SchemaObject}
@return: The leaf.
@rtype: L{xsd.sxbase.SchemaObject}
"""
name = splitPrefix(parts[-1])[1]
if name.startswith('@'):
result, path = parent.get_attribute(name[1:])
else:
result, ancestry = parent.get_child(name)
if result is None:
raise PathResolver.BadPath(name)
return result
开发者ID:BhallaLab,项目名称:moose-gui,代码行数:18,代码来源:resolver.py
示例7: get_reply
def get_reply(self, method, reply):
"""
Process the I{reply} for the specified I{method} by sax parsing the I{reply}
and then unmarshalling into python object(s).
@param method: The name of the invoked method.
@type method: str
@param reply: The reply XML received after invoking the specified method.
@type reply: str
@return: The unmarshalled reply. The returned value is an L{Object} for a
I{list} depending on whether the service returns a single object or a
collection.
@rtype: tuple ( L{Element}, L{Object} )
"""
reply = self.replyfilter(reply)
sax = Parser()
replyroot = sax.parse(string=reply)
soapenv = replyroot.getChild('Envelope')
soapenv.promotePrefixes()
soapbody = soapenv.getChild('Body')
soapbody = self.multiref.process(soapbody)
nodes = self.replycontent(method, soapbody)
rtypes = self.returned_types(method)
if len(rtypes) > 1:
result = self.replycomposite(rtypes, nodes)
return (replyroot, result)
if len(rtypes) == 1:
if rtypes[0].unbounded():
result = self.replylist(rtypes[0], nodes)
return (replyroot, result)
if len(nodes):
unmarshaller = self.unmarshaller()
resolved = rtypes[0].resolve(nobuiltin=True)
ns = nodes[0].resolvePrefix(splitPrefix(nodes[0].get("type"))[0])[1];
result = unmarshaller.process(nodes[0], resolved)
# result.__ns = ns
return (replyroot, result)
return (replyroot, None)
开发者ID:dreamindustries,项目名称:suds,代码行数:43,代码来源:binding.py
示例8: getChildren
def getChildren(self, name=None, ns=None):
"""
Get a list of children by (optional) name and/or (optional) namespace.
@param name: The name of a child element (may contain prefix).
@type name: basestring
@param ns: An optional namespace used to match the child.
@type ns: (I{prefix}, I{name})
@return: The list of matching children.
@rtype: [L{Element},...]
"""
if ns is None:
if name is None:
return self.children
prefix, name = splitPrefix(name)
if prefix is None:
ns = None
else:
ns = self.resolvePrefix(prefix)
return [c for c in self.children if c.match(name, ns)]
开发者ID:EquipmentShare,项目名称:suds-py3,代码行数:19,代码来源:element.py
示例9: builtin
def builtin(self, ref, context=None):
"""
Get whether the specified reference is an (xs) builtin.
@param ref: A str or qref.
@type ref: (str|qref)
@return: True if builtin, else False.
@rtype: bool
"""
w3 = 'http://www.w3.org'
try:
if isqref(ref):
ns = ref[1]
return ( ref[0] in Factory.tags and ns.startswith(w3) )
if context is None:
context = self.root
prefix = splitPrefix(ref)[0]
prefixes = context.findPrefixes(w3, 'startswith')
return ( prefix in prefixes and ref[0] in Factory.tags )
except:
return False
开发者ID:mrohr,项目名称:suds,代码行数:20,代码来源:schema.py
示例10: branch
def branch(self, root, parts):
"""
Traverse the path until a leaf is reached.
@param parts: A list of path parts.
@type parts: [str,..]
@param root: The root.
@type root: L{xsd.sxbase.SchemaObject}
@return: The end of the branch.
@rtype: L{xsd.sxbase.SchemaObject}
"""
result = root
for part in parts[1:-1]:
name = splitPrefix(part)[1]
log.debug('searching parent (%s) for (%s)', Repr(result), name)
result, ancestry = result.get_child(name)
if result is None:
log.error('(%s) not-found', name)
raise PathResolver.BadPath(name)
result = result.resolve(nobuiltin=True)
log.debug('found (%s) as (%s)', name, Repr(result))
return result
开发者ID:BhallaLab,项目名称:moose-gui,代码行数:21,代码来源:resolver.py
示例11: childAtPath
def childAtPath(self, path):
"""
Get a child at I{path} where I{path} is a (/) separated
list of element names that are expected to be children.
@param path: A (/) separated list of element names.
@type path: basestring
@return: The leaf node at the end of I{path}
@rtype: L{Element}
"""
result = None
node = self
for name in [p for p in path.split('/') if len(p) > 0]:
ns = None
prefix, name = splitPrefix(name)
if prefix is not None:
ns = node.resolvePrefix(prefix)
result = node.getChild(name, ns)
if result is None:
break
else:
node = result
return result
开发者ID:EquipmentShare,项目名称:suds-py3,代码行数:22,代码来源:element.py
示例12: getChild
def getChild(self, name, ns=None, default=None):
"""
Get a child by (optional) name and/or (optional) namespace.
@param name: The name of a child element (may contain prefix).
@type name: basestring
@param ns: An optional namespace used to match the child.
@type ns: (I{prefix}, I{name})
@param default: Returned when child not-found.
@type default: L{Element}
@return: The requested child, or I{default} when not-found.
@rtype: L{Element}
"""
if ns is None:
prefix, name = splitPrefix(name)
if prefix is None:
ns = None
else:
ns = self.resolvePrefix(prefix)
for c in self.children:
if c.match(name, ns):
return c
return default
开发者ID:EquipmentShare,项目名称:suds-py3,代码行数:22,代码来源:element.py
示例13: getAttribute
def getAttribute(self, name, ns=None, default=None):
"""
Get an attribute by name and (optional) namespace
@param name: The name of a contained attribute (may contain prefix).
@type name: basestring
@param ns: An optional namespace
@type ns: (I{prefix}, I{name})
@param default: Returned when attribute not-found.
@type default: L{Attribute}
@return: The requested attribute object.
@rtype: L{Attribute}
"""
if ns is None:
prefix, name = splitPrefix(name)
if prefix is None:
ns = None
else:
ns = self.resolvePrefix(prefix)
for a in self.attributes:
if a.match(name, ns):
return a
return default
开发者ID:EquipmentShare,项目名称:suds-py3,代码行数:22,代码来源:element.py
注:本文中的suds.sax.splitPrefix函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论