signature
stringlengths
8
3.44k
body
stringlengths
0
1.41M
docstring
stringlengths
1
122k
id
stringlengths
5
17
def download(self, options):
url = self.location<EOL>try:<EOL><INDENT>if '<STR_LIT>' not in url:<EOL><INDENT>url = urljoin(self.schema.baseurl, url)<EOL><DEDENT>reader = DocumentReader(options)<EOL>d = reader.open(url)<EOL>root = d.root()<EOL>root.set('<STR_LIT:url>', url)<EOL>self.__applytns(root)<EOL>return self.schema.instance(root, url, options)<EOL><DEDENT>except TransportError:<EOL><INDENT>msg = '<STR_LIT>' % url<EOL>log.error('<STR_LIT>', self.id, msg, exc_info=True)<EOL>raise Exception(msg)<EOL><DEDENT>
download the schema
f9669:c18:m2
def __applytns(self, root):
TNS = '<STR_LIT>'<EOL>tns = root.get(TNS)<EOL>if tns is None:<EOL><INDENT>tns = self.schema.tns[<NUM_LIT:1>]<EOL>root.set(TNS, tns)<EOL><DEDENT>else:<EOL><INDENT>if self.schema.tns[<NUM_LIT:1>] != tns:<EOL><INDENT>raise Exception('<STR_LIT>' % TNS)<EOL><DEDENT><DEDENT>
make sure included schema has same tns.
f9669:c18:m3
def get_default(self):
return self.root.get('<STR_LIT:default>', default='<STR_LIT>')<EOL>
Gets the <xs:attribute default=""/> attribute value. @return: The default value for the attribute @rtype: str
f9669:c19:m3
@classmethod<EOL><INDENT>def maptag(cls, tag, fn):<DEDENT>
cls.tags[tag] = fn<EOL>
Map (override) tag => I{class} mapping. @param tag: An xsd tag name. @type tag: str @param fn: A function or class. @type fn: fn|class.
f9669:c21:m0
@classmethod<EOL><INDENT>def create(cls, root, schema):<DEDENT>
fn = cls.tags.get(root.name)<EOL>if fn is not None:<EOL><INDENT>return fn(schema, root)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>
Create an object based on the root tag name. @param root: An XML root element. @type root: L{Element} @param schema: A schema object. @type schema: L{schema.Schema} @return: The created object. @rtype: L{SchemaObject}
f9669:c21:m1
@classmethod<EOL><INDENT>def build(cls, root, schema, filter=('<STR_LIT:*>',)):<DEDENT>
children = []<EOL>for node in root.getChildren(ns=Namespace.xsdns):<EOL><INDENT>if '<STR_LIT:*>' in filter or node.name in filter:<EOL><INDENT>child = cls.create(node, schema)<EOL>if child is None:<EOL><INDENT>continue<EOL><DEDENT>children.append(child)<EOL>c = cls.build(node, schema, child.childtags())<EOL>child.rawchildren = c<EOL><DEDENT><DEDENT>return children<EOL>
Build an xsobject representation. @param root: An schema XML root. @type root: L{sax.element.Element} @param filter: A tag filter. @type filter: [str,...] @return: A schema object graph. @rtype: L{sxbase.SchemaObject}
f9669:c21:m2
def __init__(self, wsdl):
self.wsdl = wsdl<EOL>self.children = []<EOL>self.namespaces = {}<EOL>
@param wsdl: A wsdl object. @type wsdl: L{suds.wsdl.Definitions}
f9670:c0:m0
def add(self, schema):
key = schema.tns[<NUM_LIT:1>]<EOL>existing = self.namespaces.get(key)<EOL>if existing is None:<EOL><INDENT>self.children.append(schema)<EOL>self.namespaces[key] = schema<EOL><DEDENT>else:<EOL><INDENT>existing.root.children += schema.root.children<EOL>existing.root.nsprefixes.update(schema.root.nsprefixes)<EOL><DEDENT>
Add a schema node to the collection. Schema(s) within the same target namespace are consolidated. @param schema: A schema object. @type schema: (L{Schema})
f9670:c0:m1
def load(self, options):
if options.autoblend:<EOL><INDENT>self.autoblend()<EOL><DEDENT>for child in self.children:<EOL><INDENT>child.build()<EOL><DEDENT>for child in self.children:<EOL><INDENT>child.open_imports(options)<EOL><DEDENT>for child in self.children:<EOL><INDENT>child.dereference()<EOL><DEDENT>log.debug('<STR_LIT>', self)<EOL>merged = self.merge()<EOL>log.debug('<STR_LIT>', merged)<EOL>return merged<EOL>
Load the schema objects for the root nodes. - de-references schemas - merge schemas @param options: An options dictionary. @type options: L{options.Options} @return: The merged schema. @rtype: L{Schema}
f9670:c0:m2
def autoblend(self):
namespaces = self.namespaces.keys()<EOL>for s in self.children:<EOL><INDENT>for ns in namespaces:<EOL><INDENT>tns = s.root.get('<STR_LIT>')<EOL>if tns == ns:<EOL><INDENT>continue<EOL><DEDENT>for imp in s.root.getChildren('<STR_LIT>'):<EOL><INDENT>if imp.get('<STR_LIT>') == ns:<EOL><INDENT>continue<EOL><DEDENT><DEDENT>imp = Element('<STR_LIT>', ns=Namespace.xsdns)<EOL>imp.set('<STR_LIT>', ns)<EOL>s.root.append(imp)<EOL><DEDENT><DEDENT>return self<EOL>
Ensure that all schemas within the collection import each other which has a blending effect. @return: self @rtype: L{SchemaCollection}
f9670:c0:m3
def locate(self, ns):
return self.namespaces.get(ns[<NUM_LIT:1>])<EOL>
Find a schema by namespace. Only the URI portion of the namespace is compared to each schema's I{targetNamespace} @param ns: A namespace. @type ns: (prefix,URI) @return: The schema matching the namesapce, else None. @rtype: L{Schema}
f9670:c0:m4
def merge(self):
if len(self):<EOL><INDENT>schema = self.children[<NUM_LIT:0>]<EOL>for s in self.children[<NUM_LIT:1>:]:<EOL><INDENT>schema.merge(s)<EOL><DEDENT>return schema<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>
Merge the contained schemas into one. @return: The merged schema. @rtype: L{Schema}
f9670:c0:m5
def __init__(self, root, baseurl, options, container=None):
self.root = root<EOL>self.id = objid(self)<EOL>self.tns = self.mktns()<EOL>self.baseurl = baseurl<EOL>self.container = container<EOL>self.children = []<EOL>self.all = []<EOL>self.types = {}<EOL>self.imports = []<EOL>self.elements = {}<EOL>self.attributes = {}<EOL>self.groups = {}<EOL>self.agrps = {}<EOL>if options.doctor is not None:<EOL><INDENT>options.doctor.examine(root)<EOL><DEDENT>form = self.root.get('<STR_LIT>')<EOL>if form is None:<EOL><INDENT>self.form_qualified = False<EOL><DEDENT>else:<EOL><INDENT>self.form_qualified = form == '<STR_LIT>'<EOL><DEDENT>if container is None:<EOL><INDENT>self.build()<EOL>self.open_imports(options)<EOL>log.debug('<STR_LIT>', self)<EOL>self.dereference()<EOL>log.debug('<STR_LIT>', self)<EOL><DEDENT>
@param root: The xml root. @type root: L{sax.element.Element} @param baseurl: The base url used for importing. @type baseurl: basestring @param options: An options dictionary. @type options: L{options.Options} @param container: An optional container. @type container: L{SchemaCollection}
f9670:c1:m0
def mktns(self):
tns = [None, self.root.get('<STR_LIT>')]<EOL>if tns[<NUM_LIT:1>] is not None:<EOL><INDENT>tns[<NUM_LIT:0>] = self.root.findPrefix(tns[<NUM_LIT:1>])<EOL><DEDENT>return tuple(tns)<EOL>
Make the schema's target namespace. @return: The namespace representation of the schema's targetNamespace value. @rtype: (prefix, uri)
f9670:c1:m1
def build(self):
self.children = BasicFactory.build(self.root, self)<EOL>collated = BasicFactory.collate(self.children)<EOL>self.children = collated[<NUM_LIT:0>]<EOL>self.attributes = collated[<NUM_LIT:2>]<EOL>self.imports = collated[<NUM_LIT:1>]<EOL>self.elements = collated[<NUM_LIT:3>]<EOL>self.types = collated[<NUM_LIT:4>]<EOL>self.groups = collated[<NUM_LIT:5>]<EOL>self.agrps = collated[<NUM_LIT:6>]<EOL>
Build the schema (object graph) using the root node using the factory. - Build the graph. - Collate the children.
f9670:c1:m2
def merge(self, schema):
for item in schema.attributes.items():<EOL><INDENT>if item[<NUM_LIT:0>] in self.attributes:<EOL><INDENT>continue<EOL><DEDENT>self.all.append(item[<NUM_LIT:1>])<EOL>self.attributes[item[<NUM_LIT:0>]] = item[<NUM_LIT:1>]<EOL><DEDENT>for item in schema.elements.items():<EOL><INDENT>if item[<NUM_LIT:0>] in self.elements:<EOL><INDENT>continue<EOL><DEDENT>self.all.append(item[<NUM_LIT:1>])<EOL>self.elements[item[<NUM_LIT:0>]] = item[<NUM_LIT:1>]<EOL><DEDENT>for item in schema.types.items():<EOL><INDENT>if item[<NUM_LIT:0>] in self.types:<EOL><INDENT>continue<EOL><DEDENT>self.all.append(item[<NUM_LIT:1>])<EOL>self.types[item[<NUM_LIT:0>]] = item[<NUM_LIT:1>]<EOL><DEDENT>for item in schema.groups.items():<EOL><INDENT>if item[<NUM_LIT:0>] in self.groups:<EOL><INDENT>continue<EOL><DEDENT>self.all.append(item[<NUM_LIT:1>])<EOL>self.groups[item[<NUM_LIT:0>]] = item[<NUM_LIT:1>]<EOL><DEDENT>for item in schema.agrps.items():<EOL><INDENT>if item[<NUM_LIT:0>] in self.agrps:<EOL><INDENT>continue<EOL><DEDENT>self.all.append(item[<NUM_LIT:1>])<EOL>self.agrps[item[<NUM_LIT:0>]] = item[<NUM_LIT:1>]<EOL><DEDENT>schema.merged = True<EOL>return self<EOL>
Merge the contents from the schema. Only objects not already contained in this schema's collections are merged. This is to provide for bidirectional import which produce cyclic includes. @returns: self @rtype: L{Schema}
f9670:c1:m3
def open_imports(self, options):
for imp in self.imports:<EOL><INDENT>imported = imp.open(options)<EOL>if imported is None:<EOL><INDENT>continue<EOL><DEDENT>imported.open_imports(options)<EOL>log.debug('<STR_LIT>', imported)<EOL>self.merge(imported)<EOL><DEDENT>
Instruct all contained L{sxbasic.Import} children to import the schema's which they reference. The contents of the imported schema are I{merged} in. @param options: An options dictionary. @type options: L{options.Options}
f9670:c1:m4
def dereference(self):
all = []<EOL>indexes = {}<EOL>for child in self.children:<EOL><INDENT>child.content(all)<EOL><DEDENT>deplist = DepList()<EOL>for x in all:<EOL><INDENT>x.qualify()<EOL>midx, deps = x.dependencies()<EOL>item = (x, tuple(deps))<EOL>deplist.add(item)<EOL>indexes[x] = midx<EOL><DEDENT>for x, deps in deplist.sort():<EOL><INDENT>midx = indexes.get(x)<EOL>if midx is None:<EOL><INDENT>continue<EOL><DEDENT>d = deps[midx]<EOL>log.debug('<STR_LIT>', self.tns[<NUM_LIT:1>], Repr(x), Repr(d))<EOL>x.merge(d)<EOL><DEDENT>
Instruct all children to perform dereferencing.
f9670:c1:m5
def locate(self, ns):
if self.container is not None:<EOL><INDENT>return self.container.locate(ns)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>
Find a schema by namespace. Only the URI portion of the namespace is compared to each schema's I{targetNamespace}. The request is passed to the container. @param ns: A namespace. @type ns: (prefix,URI) @return: The schema matching the namesapce, else None. @rtype: L{Schema}
f9670:c1:m6
def custom(self, ref, context=None):
if ref is None:<EOL><INDENT>return True<EOL><DEDENT>else:<EOL><INDENT>return not self.builtin(ref, context)<EOL><DEDENT>
Get whether the specified reference is B{not} an (xs) builtin. @param ref: A str or qref. @type ref: (str|qref) @return: True if B{not} a builtin, else False. @rtype: bool
f9670:c1:m7
def builtin(self, ref, context=None):
w3 = '<STR_LIT>'<EOL>try:<EOL><INDENT>if isqref(ref):<EOL><INDENT>ns = ref[<NUM_LIT:1>]<EOL>return ref[<NUM_LIT:0>] in Factory.tags and ns.startswith(w3)<EOL><DEDENT>if context is None:<EOL><INDENT>context = self.root<EOL><DEDENT>prefix = splitPrefix(ref)[<NUM_LIT:0>]<EOL>prefixes = context.findPrefixes(w3, '<STR_LIT>')<EOL>return prefix in prefixes and ref[<NUM_LIT:0>] in Factory.tags<EOL><DEDENT>except:<EOL><INDENT>return False<EOL><DEDENT>
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
f9670:c1:m8
def instance(self, root, baseurl, options):
return Schema(root, baseurl, options)<EOL>
Create and return an new schema object using the specified I{root} and I{url}. @param root: A schema root node. @type root: L{sax.element.Element} @param baseurl: A base URL. @type baseurl: str @param options: An options dictionary. @type options: L{options.Options} @return: The newly created schema object. @rtype: L{Schema} @note: This is only used by Import children.
f9670:c1:m9
def __init__(self, ref=None):
Object.__init__(self)<EOL>self.id = objid(self)<EOL>self.ref = ref<EOL>self.history = []<EOL>self.resolved = False<EOL>if not isqref(self.ref):<EOL><INDENT>raise Exception('<STR_LIT>' % tostr(self.ref))<EOL><DEDENT>
@param ref: The schema reference being queried. @type ref: qref
f9671:c0:m0
def execute(self, schema):
raise Exception('<STR_LIT>')<EOL>
Execute this query using the specified schema. @param schema: The schema associated with the query. The schema is used by the query to search for items. @type schema: L{schema.Schema} @return: The item matching the search criteria. @rtype: L{sxbase.SchemaObject}
f9671:c0:m1
def filter(self, result):
if result is None:<EOL><INDENT>return True<EOL><DEDENT>reject = result in self.history<EOL>if reject:<EOL><INDENT>log.debug('<STR_LIT>', Repr(result), self)<EOL><DEDENT>return reject<EOL>
Filter the specified result based on query criteria. @param result: A potential result. @type result: L{sxbase.SchemaObject} @return: True if result should be excluded. @rtype: boolean
f9671:c0:m2
def result(self, result):
if result is None:<EOL><INDENT>log.debug('<STR_LIT>', self.ref)<EOL>return<EOL><DEDENT>if self.resolved:<EOL><INDENT>result = result.resolve()<EOL><DEDENT>log.debug('<STR_LIT>', self.ref, Repr(result))<EOL>self.history.append(result)<EOL>return result<EOL>
Query result post processing. @param result: A query result. @type result: L{sxbase.SchemaObject}
f9671:c0:m3
def qualify(ref, resolvers, defns=Namespace.default):
ns = None<EOL>p, n = splitPrefix(ref)<EOL>if p is not None:<EOL><INDENT>if not isinstance(resolvers, (list, tuple)):<EOL><INDENT>resolvers = (resolvers,)<EOL><DEDENT>for r in resolvers:<EOL><INDENT>resolved = r.resolvePrefix(p)<EOL>if resolved[<NUM_LIT:1>] is not None:<EOL><INDENT>ns = resolved<EOL>break<EOL><DEDENT><DEDENT>if ns is None:<EOL><INDENT>raise Exception('<STR_LIT>' % p)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>ns = defns<EOL><DEDENT>return (n, ns[<NUM_LIT:1>])<EOL>
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)
f9672:m0
def isqref(object):
return (<EOL>isinstance(object, tuple) and<EOL>len(object) == <NUM_LIT:2> and<EOL>isinstance(object[<NUM_LIT:0>], basestring) and<EOL>isinstance(object[<NUM_LIT:1>], basestring))<EOL>
Get whether the object is a I{qualified reference}. @param object: An object to be tested. @type object: I{any} @rtype: boolean @see: L{qualify}
f9672:m1
def add(self, *items):
for item in items:<EOL><INDENT>self.unsorted.append(item)<EOL>key = item[<NUM_LIT:0>]<EOL>self.index[key] = item<EOL><DEDENT>return self<EOL>
Add items to be sorted. @param items: One or more items to be added. @type items: I{item} @return: self @rtype: L{DepList}
f9673:c0:m1
def sort(self):
self.sorted = list()<EOL>self.pushed = set()<EOL>for item in self.unsorted:<EOL><INDENT>popped = []<EOL>self.push(item)<EOL>while len(self.stack):<EOL><INDENT>try:<EOL><INDENT>top = self.top()<EOL>ref = next(top[<NUM_LIT:1>])<EOL>refd = self.index.get(ref)<EOL>if refd is None:<EOL><INDENT>log.debug('<STR_LIT>', Repr(ref))<EOL>continue<EOL><DEDENT>self.push(refd)<EOL><DEDENT>except StopIteration:<EOL><INDENT>popped.append(self.pop())<EOL>continue<EOL><DEDENT><DEDENT>for p in popped:<EOL><INDENT>self.sorted.append(p)<EOL><DEDENT><DEDENT>self.unsorted = self.sorted<EOL>return self.sorted<EOL>
Sort the list based on dependancies. @return: The sorted items. @rtype: list
f9673:c0:m2
def top(self):
return self.stack[-<NUM_LIT:1>]<EOL>
Get the item at the top of the stack. @return: The top item. @rtype: (item, iter)
f9673:c0:m3
def push(self, item):
if item in self.pushed:<EOL><INDENT>return<EOL><DEDENT>frame = (item, iter(item[<NUM_LIT:1>]))<EOL>self.stack.append(frame)<EOL>self.pushed.add(item)<EOL>
Push and item onto the sorting stack. @param item: An item to push. @type item: I{item} @return: The number of items pushed. @rtype: int
f9673:c0:m4
def pop(self):
try:<EOL><INDENT>frame = self.stack.pop()<EOL>return frame[<NUM_LIT:0>]<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>
Pop the top item off the stack and append it to the sorted list. @return: The popped item. @rtype: I{item}
f9673:c0:m5
@classmethod<EOL><INDENT>def maptag(cls, tag, fn):<DEDENT>
cls.tags[tag] = fn<EOL>
Map (override) tag => I{class} mapping. @param tag: An xsd tag name. @type tag: str @param fn: A function or class. @type fn: fn|class.
f9674:c9:m0
@classmethod<EOL><INDENT>def create(cls, schema, name):<DEDENT>
fn = cls.tags.get(name)<EOL>if fn is not None:<EOL><INDENT>return fn(schema, name)<EOL><DEDENT>else:<EOL><INDENT>return XBuiltin(schema, name)<EOL><DEDENT>
Create an object based on the root tag name. @param schema: A schema object. @type schema: L{schema.Schema} @param name: The name. @type name: str @return: The created object. @rtype: L{XBuiltin}
f9674:c9:m1
def __init__(self, wsdl, service):
self.wsdl = wsdl<EOL>self.service = service<EOL>self.ports = []<EOL>self.params = []<EOL>self.types = []<EOL>self.prefixes = []<EOL>self.addports()<EOL>self.paramtypes()<EOL>self.publictypes()<EOL>self.getprefixes()<EOL>self.pushprefixes()<EOL>
@param wsdl: A wsdl object @type wsdl: L{Definitions} @param service: A service B{name}. @type service: str
f9675:c0:m0
def pushprefixes(self):
for ns in self.prefixes:<EOL><INDENT>self.wsdl.root.addPrefix(ns[<NUM_LIT:0>], ns[<NUM_LIT:1>])<EOL><DEDENT>
Add our prefixes to the wsdl so that when users invoke methods and reference the prefixes, the will resolve properly.
f9675:c0:m1
def addports(self):
timer = metrics.Timer()<EOL>timer.start()<EOL>for port in self.service.ports:<EOL><INDENT>p = self.findport(port)<EOL>for op in port.binding.operations.values():<EOL><INDENT>m = p[<NUM_LIT:0>].method(op.name)<EOL>binding = m.binding.input<EOL>method = (m.name, binding.param_defs(m))<EOL>p[<NUM_LIT:1>].append(method)<EOL>metrics.log.debug("<STR_LIT>", m.name, timer)<EOL><DEDENT>p[<NUM_LIT:1>].sort()<EOL><DEDENT>timer.stop()<EOL>
Look through the list of service ports and construct a list of tuples where each tuple is used to describe a port and it's list of methods as: (port, [method]). Each method is tuple: (name, [pdef,..] where each pdef is a tuple: (param-name, type).
f9675:c0:m2
def findport(self, port):
for p in self.ports:<EOL><INDENT>if p[<NUM_LIT:0>] == p:<EOL><INDENT>return p<EOL><DEDENT><DEDENT>p = (port, [])<EOL>self.ports.append(p)<EOL>return p<EOL>
Find and return a port tuple for the specified port. Created and added when not found. @param port: A port. @type port: I{service.Port} @return: A port tuple. @rtype: (port, [method])
f9675:c0:m3
def getprefixes(self):
namespaces = []<EOL>for l in (self.params, self.types):<EOL><INDENT>for t, r in l:<EOL><INDENT>ns = r.namespace()<EOL>if ns[<NUM_LIT:1>] is None:<EOL><INDENT>continue<EOL><DEDENT>if ns[<NUM_LIT:1>] in namespaces:<EOL><INDENT>continue<EOL><DEDENT>if Namespace.xs(ns) or Namespace.xsd(ns):<EOL><INDENT>continue<EOL><DEDENT>namespaces.append(ns[<NUM_LIT:1>])<EOL>if t == r:<EOL><INDENT>continue<EOL><DEDENT>ns = t.namespace()<EOL>if ns[<NUM_LIT:1>] is None:<EOL><INDENT>continue<EOL><DEDENT>if ns[<NUM_LIT:1>] in namespaces:<EOL><INDENT>continue<EOL><DEDENT>namespaces.append(ns[<NUM_LIT:1>])<EOL><DEDENT><DEDENT>namespaces.sort()<EOL>for u in namespaces:<EOL><INDENT>p = self.nextprefix()<EOL>ns = (p, u)<EOL>self.prefixes.append(ns)<EOL><DEDENT>
Add prefixes foreach namespace referenced by parameter types.
f9675:c0:m4
def paramtypes(self):
for m in [p[<NUM_LIT:1>] for p in self.ports]:<EOL><INDENT>for p in [p[<NUM_LIT:1>] for p in m]:<EOL><INDENT>for pd in p:<EOL><INDENT>if pd[<NUM_LIT:1>] in self.params:<EOL><INDENT>continue<EOL><DEDENT>item = (pd[<NUM_LIT:1>], pd[<NUM_LIT:1>].resolve())<EOL>self.params.append(item)<EOL><DEDENT><DEDENT><DEDENT>
get all parameter types
f9675:c0:m5
def publictypes(self):
for t in self.wsdl.schema.types.values():<EOL><INDENT>if t in self.params:<EOL><INDENT>continue<EOL><DEDENT>if t in self.types:<EOL><INDENT>continue<EOL><DEDENT>item = (t, t)<EOL>self.types.append(item)<EOL><DEDENT>self.types.sort(key=lambda x: x[<NUM_LIT:0>].name)<EOL>
get all public types
f9675:c0:m6
def nextprefix(self):
used = [ns[<NUM_LIT:0>] for ns in self.prefixes]<EOL>used += [ns[<NUM_LIT:0>] for ns in self.wsdl.root.nsprefixes.items()]<EOL>for n in range(<NUM_LIT:0>, <NUM_LIT>):<EOL><INDENT>p = '<STR_LIT>' % n<EOL>if p not in used:<EOL><INDENT>return p<EOL><DEDENT><DEDENT>raise Exception('<STR_LIT>')<EOL>
Get the next available prefix. This means a prefix starting with 'ns' with a number appended as (ns0, ns1, ..) that is not already defined on the wsdl document.
f9675:c0:m7
def getprefix(self, u):
for ns in Namespace.all:<EOL><INDENT>if u == ns[<NUM_LIT:1>]:<EOL><INDENT>return ns[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>for ns in self.prefixes:<EOL><INDENT>if u == ns[<NUM_LIT:1>]:<EOL><INDENT>return ns[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>raise Exception('<STR_LIT>' % u)<EOL>
Get the prefix for the specified namespace (uri) @param u: A namespace uri. @type u: str @return: The namspace. @rtype: (prefix, uri).
f9675:c0:m8
def xlate(self, type):
resolved = type.resolve()<EOL>name = resolved.name<EOL>if type.unbounded():<EOL><INDENT>name += '<STR_LIT>'<EOL><DEDENT>ns = resolved.namespace()<EOL>if ns[<NUM_LIT:1>] == self.wsdl.tns[<NUM_LIT:1>]:<EOL><INDENT>return name<EOL><DEDENT>prefix = self.getprefix(ns[<NUM_LIT:1>])<EOL>return '<STR_LIT::>'.join((prefix, name))<EOL>
Get a (namespace) translated I{qualified} name for specified type. @param type: A schema type. @type type: I{suds.xsd.sxbasic.SchemaObject} @return: A translated I{qualified} name. @rtype: str
f9675:c0:m9
def description(self, html=False):
s = []<EOL>if html:<EOL><INDENT>indent = lambda n: '<STR_LIT>' % (n * <NUM_LIT:3>, '<STR_LIT:U+0020>')<EOL>line = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>indent = lambda n: '<STR_LIT>' % (n * <NUM_LIT:3>, '<STR_LIT:U+0020>')<EOL>line = '<STR_LIT:\n>' + '<STR_LIT:->'*<NUM_LIT><EOL><DEDENT>s.append('<STR_LIT>' %<EOL>(self.service.name, self.wsdl.tns[<NUM_LIT:1>]))<EOL>s.append(indent(<NUM_LIT:1>))<EOL>s.append('<STR_LIT>' % len(self.prefixes))<EOL>for p in self.prefixes:<EOL><INDENT>s.append(indent(<NUM_LIT:2>))<EOL>s.append('<STR_LIT>' % p)<EOL><DEDENT>s.append(indent(<NUM_LIT:1>))<EOL>s.append('<STR_LIT>' % len(self.ports))<EOL>for p in self.ports:<EOL><INDENT>s.append(indent(<NUM_LIT:2>))<EOL>s.append('<STR_LIT>' % p[<NUM_LIT:0>].name)<EOL>s.append(indent(<NUM_LIT:3>))<EOL>s.append('<STR_LIT>' % len(p[<NUM_LIT:1>]))<EOL>for m in p[<NUM_LIT:1>]:<EOL><INDENT>sig = []<EOL>s.append(indent(<NUM_LIT:4>))<EOL>sig.append(m[<NUM_LIT:0>])<EOL>sig.append('<STR_LIT:(>')<EOL>for p in m[<NUM_LIT:1>]:<EOL><INDENT>sig.append(self.xlate(p[<NUM_LIT:1>]))<EOL>sig.append('<STR_LIT:U+0020>')<EOL>sig.append(p[<NUM_LIT:0>])<EOL>sig.append('<STR_LIT:U+002CU+0020>')<EOL><DEDENT>sig.append('<STR_LIT:)>')<EOL>try:<EOL><INDENT>s.append('<STR_LIT>'.join(sig))<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>s.append(indent(<NUM_LIT:3>))<EOL>s.append('<STR_LIT>' % len(self.types))<EOL>for t in self.types:<EOL><INDENT>s.append(indent(<NUM_LIT:4>))<EOL>s.append(self.xlate(t[<NUM_LIT:0>]))<EOL><DEDENT><DEDENT>s.append(line)<EOL>return '<STR_LIT>'.join(s)<EOL>
Get a textual description of the service for which this object represents. @return: A textual description. @rtype: str
f9675:c0:m10
def get(self, id):
raise Exception('<STR_LIT>')<EOL>
Get a object from the cache by ID. @param id: The object ID. @type id: str @return: The object, else None @rtype: any
f9677:c0:m0
def getf(self, id):
raise Exception('<STR_LIT>')<EOL>
Get a object from the cache by ID. @param id: The object ID. @type id: str @return: The object, else None @rtype: any
f9677:c0:m1
def put(self, id, object):
raise Exception('<STR_LIT>')<EOL>
Put a object into the cache. @param id: The object ID. @type id: str @param object: The object to add. @type object: any
f9677:c0:m2
def putf(self, id, fp):
raise Exception('<STR_LIT>')<EOL>
Write a fp into the cache. @param id: The object ID. @type id: str @param fp: File pointer. @type fp: file-like object.
f9677:c0:m3
def purge(self, id):
raise Exception('<STR_LIT>')<EOL>
Purge a object from the cache by id. @param id: A object ID. @type id: str
f9677:c0:m4
def clear(self):
raise Exception('<STR_LIT>')<EOL>
Clear all objects from the cache.
f9677:c0:m5
def __init__(self, location=None, **duration):
if location is None:<EOL><INDENT>location = os.path.join(tmp(), '<STR_LIT>')<EOL><DEDENT>self.location = location<EOL>self.duration = (None, <NUM_LIT:0>)<EOL>self.setduration(**duration)<EOL>self.checkversion()<EOL>
@param location: The directory for the cached files. @type location: str @param duration: The cached file duration which defines how long the file will be cached. A duration=0 means forever. The duration may be: (months|weeks|days|hours|minutes|seconds). @type duration: {unit:value}
f9677:c2:m0
def fnsuffix(self):
return '<STR_LIT>'<EOL>
Get the file name suffix @return: The suffix @rtype: str
f9677:c2:m1
def setduration(self, **duration):
if len(duration) == <NUM_LIT:1>:<EOL><INDENT>arg = [x[<NUM_LIT:0>] for x in duration.items()]<EOL>if not arg[<NUM_LIT:0>] in self.units:<EOL><INDENT>raise Exception('<STR_LIT>' % str(self.units))<EOL><DEDENT>self.duration = arg<EOL><DEDENT>return self<EOL>
Set the caching duration which defines how long the file will be cached. @param duration: The cached file duration which defines how long the file will be cached. A duration=0 means forever. The duration may be: (months|weeks|days|hours|minutes|seconds). @type duration: {unit:value}
f9677:c2:m2
def setlocation(self, location):
self.location = location<EOL>
Set the location (directory) for the cached files. @param location: The directory for the cached files. @type location: str
f9677:c2:m3
def mktmp(self):
try:<EOL><INDENT>if not os.path.isdir(self.location):<EOL><INDENT>os.makedirs(self.location)<EOL><DEDENT><DEDENT>except:<EOL><INDENT>log.debug(self.location, exc_info=<NUM_LIT:1>)<EOL><DEDENT>return self<EOL>
Make the I{location} directory if it doesn't already exits.
f9677:c2:m4
def validate(self, fn):
if self.duration[<NUM_LIT:1>] < <NUM_LIT:1>:<EOL><INDENT>return<EOL><DEDENT>created = dt.fromtimestamp(os.path.getctime(fn))<EOL>d = {self.duration[<NUM_LIT:0>]: self.duration[<NUM_LIT:1>]}<EOL>expired = created+timedelta(**d)<EOL>if expired < dt.now():<EOL><INDENT>log.debug('<STR_LIT>', fn)<EOL>os.remove(fn)<EOL><DEDENT>
Validate that the file has not expired based on the I{duration}. @param fn: The file name. @type fn: str
f9677:c2:m9
def open(self, fn, *args):
self.mktmp()<EOL>return open(fn, *args)<EOL>
Open the cache file making sure the directory is created.
f9677:c2:m12
def __init__(self, schema, root, aty):
SXAttribute.__init__(self, schema, root)<EOL>if aty.endswith('<STR_LIT>'):<EOL><INDENT>self.aty = aty[:-<NUM_LIT:2>]<EOL><DEDENT>else:<EOL><INDENT>self.aty = aty<EOL><DEDENT>
@param aty: Array type information. @type aty: The value of wsdl:arrayType.
f9678:c0:m0
def __init__(self, schema):
self.schema = schema<EOL>
@param schema: A schema object. @type schema: L{xsd.schema.Schema}
f9679:c0:m0
def find(self, name, resolved=True):
log.debug('<STR_LIT>', name)<EOL>qref = qualify(name, self.schema.root, self.schema.tns)<EOL>query = BlindQuery(qref)<EOL>result = query.execute(self.schema)<EOL>if result is None:<EOL><INDENT>log.error('<STR_LIT>', name)<EOL>return None<EOL><DEDENT>log.debug('<STR_LIT>', name, Repr(result))<EOL>if resolved:<EOL><INDENT>result = result.resolve()<EOL><DEDENT>return result<EOL>
Get the definition object for the schema object by name. @param name: The name of a schema object. @type name: basestring @param resolved: A flag indicating that the fully resolved type should be returned. @type resolved: boolean @return: The found schema I{type} @rtype: L{xsd.sxbase.SchemaObject}
f9679:c0:m1
def __init__(self, wsdl, ps='<STR_LIT:.>'):
Resolver.__init__(self, wsdl.schema)<EOL>self.wsdl = wsdl<EOL>self.altp = re.compile('<STR_LIT>')<EOL>self.splitp = re.compile('<STR_LIT>' % ps[<NUM_LIT:0>])<EOL>
@param wsdl: A schema object. @type wsdl: L{wsdl.Definitions} @param ps: The path separator character @type ps: char
f9679:c1:m0
def find(self, path, resolved=True):
result = None<EOL>parts = self.split(path)<EOL>try:<EOL><INDENT>result = self.root(parts)<EOL>if len(parts) > <NUM_LIT:1>:<EOL><INDENT>result = result.resolve(nobuiltin=True)<EOL>result = self.branch(result, parts)<EOL>result = self.leaf(result, parts)<EOL><DEDENT>if resolved:<EOL><INDENT>result = result.resolve(nobuiltin=True)<EOL><DEDENT><DEDENT>except PathResolver.BadPath:<EOL><INDENT>log.error('<STR_LIT>' % path)<EOL><DEDENT>return result<EOL>
Get the definition object for the schema type located at the specified path. The path may contain (.) dot notation to specify nested types. Actually, the path separator is usually a (.) but can be redefined during contruction. @param path: A (.) separated path to a schema type. @type path: basestring @param resolved: A flag indicating that the fully resolved type should be returned. @type resolved: boolean @return: The found schema I{type} @rtype: L{xsd.sxbase.SchemaObject}
f9679:c1:m1
def root(self, parts):
result = None<EOL>name = parts[<NUM_LIT:0>]<EOL>log.debug('<STR_LIT>', name)<EOL>qref = self.qualify(parts[<NUM_LIT:0>])<EOL>query = BlindQuery(qref)<EOL>result = query.execute(self.schema)<EOL>if result is None:<EOL><INDENT>log.error('<STR_LIT>', name)<EOL>raise PathResolver.BadPath(name)<EOL><DEDENT>else:<EOL><INDENT>log.debug('<STR_LIT>', name, Repr(result))<EOL><DEDENT>return result<EOL>
Find the path root. @param parts: A list of path parts. @type parts: [str,..] @return: The root. @rtype: L{xsd.sxbase.SchemaObject}
f9679:c1:m2
def branch(self, root, parts):
result = root<EOL>for part in parts[<NUM_LIT:1>:-<NUM_LIT:1>]:<EOL><INDENT>name = splitPrefix(part)[<NUM_LIT:1>]<EOL>log.debug('<STR_LIT>', Repr(result), name)<EOL>result, ancestry = result.get_child(name)<EOL>if result is None:<EOL><INDENT>log.error('<STR_LIT>', name)<EOL>raise PathResolver.BadPath(name)<EOL><DEDENT>else:<EOL><INDENT>result = result.resolve(nobuiltin=True)<EOL>log.debug('<STR_LIT>', name, Repr(result))<EOL><DEDENT><DEDENT>return result<EOL>
Traverse the path until the 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}
f9679:c1:m3
def leaf(self, parent, parts):
name = splitPrefix(parts[-<NUM_LIT:1>])[<NUM_LIT:1>]<EOL>if name.startswith('<STR_LIT:@>'):<EOL><INDENT>result, path = parent.get_attribute(name[<NUM_LIT:1>:])<EOL><DEDENT>else:<EOL><INDENT>result, ancestry = parent.get_child(name)<EOL><DEDENT>if result is None:<EOL><INDENT>raise PathResolver.BadPath(name)<EOL><DEDENT>return result<EOL>
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}
f9679:c1:m4
def qualify(self, name):
m = self.altp.match(name)<EOL>if m is None:<EOL><INDENT>return qualify(name, self.wsdl.root, self.wsdl.tns)<EOL><DEDENT>else:<EOL><INDENT>return (m.group(<NUM_LIT:4>), m.group(<NUM_LIT:2>))<EOL><DEDENT>
Qualify the name as either: - plain name - ns prefixed name (eg: ns0:Person) - fully ns qualified name (eg: {http://myns-uri}Person) @param name: The name of an object in the schema. @type name: str @return: A qualifed name. @rtype: qname
f9679:c1:m5
def split(self, s):
parts = []<EOL>b = <NUM_LIT:0><EOL>while <NUM_LIT:1>:<EOL><INDENT>m = self.splitp.match(s, b)<EOL>if m is None:<EOL><INDENT>break<EOL><DEDENT>b, e = m.span()<EOL>parts.append(s[b:e])<EOL>b = e + <NUM_LIT:1><EOL><DEDENT>return parts<EOL>
Split the string on (.) while preserving any (.) inside the '{}' alternalte syntax for full ns qualification. @param s: A plain or qualifed name. @type s: str @return: A list of the name's parts. @rtype: [str,..]
f9679:c1:m6
def __init__(self, schema):
Resolver.__init__(self, schema)<EOL>self.stack = Stack()<EOL>
@param schema: A schema object. @type schema: L{xsd.schema.Schema}
f9679:c2:m0
def reset(self):
self.stack = Stack()<EOL>
Reset the resolver's state.
f9679:c2:m1
def push(self, x):
if isinstance(x, Frame):<EOL><INDENT>frame = x<EOL><DEDENT>else:<EOL><INDENT>frame = Frame(x)<EOL><DEDENT>self.stack.append(frame)<EOL>log.debug('<STR_LIT>', Repr(frame), Repr(self.stack))<EOL>return frame<EOL>
Push an I{object} onto the stack. @param x: An object to push. @type x: L{Frame} @return: The pushed frame. @rtype: L{Frame}
f9679:c2:m2
def top(self):
if len(self.stack):<EOL><INDENT>return self.stack[-<NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>return Frame.Empty()<EOL><DEDENT>
Get the I{frame} at the top of the stack. @return: The top I{frame}, else None. @rtype: L{Frame}
f9679:c2:m3
def pop(self):
if len(self.stack):<EOL><INDENT>popped = self.stack.pop()<EOL>log.debug('<STR_LIT>', Repr(popped), Repr(self.stack))<EOL>return popped<EOL><DEDENT>else:<EOL><INDENT>log.debug('<STR_LIT>')<EOL><DEDENT>return None<EOL>
Pop the frame at the top of the stack. @return: The popped frame, else None. @rtype: L{Frame}
f9679:c2:m4
def depth(self):
return len(self.stack)<EOL>
Get the current stack depth. @return: The current stack depth. @rtype: int
f9679:c2:m5
def getchild(self, name, parent):
log.debug('<STR_LIT>', Repr(parent), name)<EOL>if name.startswith('<STR_LIT:@>'):<EOL><INDENT>return parent.get_attribute(name[<NUM_LIT:1>:])<EOL><DEDENT>else:<EOL><INDENT>return parent.get_child(name)<EOL><DEDENT>
get a child by name
f9679:c2:m6
def __init__(self, schema):
TreeResolver.__init__(self, schema)<EOL>
@param schema: A schema object. @type schema: L{xsd.schema.Schema}
f9679:c3:m0
def find(self, node, resolved=False, push=True):
name = node.name<EOL>parent = self.top().resolved<EOL>if parent is None:<EOL><INDENT>result, ancestry = self.query(name, node)<EOL><DEDENT>else:<EOL><INDENT>result, ancestry = self.getchild(name, parent)<EOL><DEDENT>known = self.known(node)<EOL>if result is None:<EOL><INDENT>return result<EOL><DEDENT>if push:<EOL><INDENT>frame = Frame(result, resolved=known, ancestry=ancestry)<EOL>self.push(frame)<EOL><DEDENT>if resolved:<EOL><INDENT>result = result.resolve()<EOL><DEDENT>return result<EOL>
@param node: An xml node to be resolved. @type node: L{sax.element.Element} @param resolved: A flag indicating that the fully resolved type should be returned. @type resolved: boolean @param push: Indicates that the resolved type should be pushed onto the stack. @type push: boolean @return: The found schema I{type} @rtype: L{xsd.sxbase.SchemaObject}
f9679:c3:m1
def findattr(self, name, resolved=True):
name = '<STR_LIT>' % name<EOL>parent = self.top().resolved<EOL>if parent is None:<EOL><INDENT>result, ancestry = self.query(name, node)<EOL><DEDENT>else:<EOL><INDENT>result, ancestry = self.getchild(name, parent)<EOL><DEDENT>if result is None:<EOL><INDENT>return result<EOL><DEDENT>if resolved:<EOL><INDENT>result = result.resolve()<EOL><DEDENT>return result<EOL>
Find an attribute type definition. @param name: An attribute name. @type name: basestring @param resolved: A flag indicating that the fully resolved type should be returned. @type resolved: boolean @return: The found schema I{type} @rtype: L{xsd.sxbase.SchemaObject}
f9679:c3:m2
def query(self, name, node):
log.debug('<STR_LIT>', name)<EOL>qref = qualify(name, node, node.namespace())<EOL>query = BlindQuery(qref)<EOL>result = query.execute(self.schema)<EOL>return (result, [])<EOL>
blindly query the schema by name
f9679:c3:m3
def known(self, node):
ref = node.get('<STR_LIT:type>', Namespace.xsins)<EOL>if ref is None:<EOL><INDENT>return None<EOL><DEDENT>qref = qualify(ref, node, node.namespace())<EOL>query = BlindQuery(qref)<EOL>return query.execute(self.schema)<EOL>
resolve type referenced by @xsi:type
f9679:c3:m4
def __init__(self, schema):
TreeResolver.__init__(self, schema)<EOL>
@param schema: A schema object. @type schema: L{xsd.schema.Schema}
f9679:c4:m0
def find(self, name, object, resolved=False, push=True):
known = None<EOL>parent = self.top().resolved<EOL>if parent is None:<EOL><INDENT>result, ancestry = self.query(name)<EOL><DEDENT>else:<EOL><INDENT>result, ancestry = self.getchild(name, parent)<EOL><DEDENT>if result is None:<EOL><INDENT>return None<EOL><DEDENT>if isinstance(object, Object):<EOL><INDENT>known = self.known(object)<EOL><DEDENT>if push:<EOL><INDENT>frame = Frame(result, resolved=known, ancestry=ancestry)<EOL>self.push(frame)<EOL><DEDENT>if resolved:<EOL><INDENT>if known is None:<EOL><INDENT>result = result.resolve()<EOL><DEDENT>else:<EOL><INDENT>result = known<EOL><DEDENT><DEDENT>return result<EOL>
@param name: The name of the object to be resolved. @type name: basestring @param object: The name's value. @type object: (any|L{Object}) @param resolved: A flag indicating that the fully resolved type should be returned. @type resolved: boolean @param push: Indicates that the resolved type should be pushed onto the stack. @type push: boolean @return: The found schema I{type} @rtype: L{xsd.sxbase.SchemaObject}
f9679:c4:m1
def query(self, name):
log.debug('<STR_LIT>', name)<EOL>schema = self.schema<EOL>wsdl = self.wsdl()<EOL>if wsdl is None:<EOL><INDENT>qref = qualify(name, schema.root, schema.tns)<EOL><DEDENT>else:<EOL><INDENT>qref = qualify(name, wsdl.root, wsdl.tns)<EOL><DEDENT>query = BlindQuery(qref)<EOL>result = query.execute(schema)<EOL>return (result, [])<EOL>
blindly query the schema by name
f9679:c4:m2
def wsdl(self):
container = self.schema.container<EOL>if container is None:<EOL><INDENT>return None<EOL><DEDENT>else:<EOL><INDENT>return container.wsdl<EOL><DEDENT>
get the wsdl
f9679:c4:m3
def known(self, object):
try:<EOL><INDENT>md = object.__metadata__<EOL>known = md.sxtype<EOL>return known<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>
get the type specified in the object's metadata
f9679:c4:m4
def __init__(self, resolver):
self.resolver = resolver<EOL>
@param resolver: A schema object name resolver. @type resolver: L{resolver.Resolver}
f9680:c0:m0
def build(self, name):
if isinstance(name, basestring):<EOL><INDENT>type = self.resolver.find(name)<EOL>if type is None:<EOL><INDENT>raise TypeNotFound(name)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>type = name<EOL><DEDENT>cls = type.name<EOL>if type.mixed():<EOL><INDENT>data = Factory.property(cls)<EOL><DEDENT>else:<EOL><INDENT>data = Factory.object(cls)<EOL><DEDENT>resolved = type.resolve()<EOL>md = data.__metadata__<EOL>md.sxtype = resolved<EOL>md.ordering = self.ordering(resolved)<EOL>history = []<EOL>self.add_attributes(data, resolved)<EOL>for child, ancestry in type.children():<EOL><INDENT>if self.skip_child(child, ancestry):<EOL><INDENT>continue<EOL><DEDENT>self.process(data, child, history[:])<EOL><DEDENT>return data<EOL>
build an object for the specified typename as defined in the schema
f9680:c0:m1
def process(self, data, type, history):
if type in history:<EOL><INDENT>return<EOL><DEDENT>if type.enum():<EOL><INDENT>return<EOL><DEDENT>history.append(type)<EOL>resolved = type.resolve()<EOL>value = None<EOL>if type.unbounded():<EOL><INDENT>value = []<EOL><DEDENT>else:<EOL><INDENT>if len(resolved) > <NUM_LIT:0>:<EOL><INDENT>if resolved.mixed():<EOL><INDENT>value = Factory.property(resolved.name)<EOL>md = value.__metadata__<EOL>md.sxtype = resolved<EOL><DEDENT>else:<EOL><INDENT>value = Factory.object(resolved.name)<EOL>md = value.__metadata__<EOL>md.sxtype = resolved<EOL>md.ordering = self.ordering(resolved)<EOL><DEDENT><DEDENT><DEDENT>setattr(data, type.name, value)<EOL>if value is not None:<EOL><INDENT>data = value<EOL><DEDENT>if not isinstance(data, list):<EOL><INDENT>self.add_attributes(data, resolved)<EOL>for child, ancestry in resolved.children():<EOL><INDENT>if self.skip_child(child, ancestry):<EOL><INDENT>continue<EOL><DEDENT>self.process(data, child, history[:])<EOL><DEDENT><DEDENT>
process the specified type then process its children
f9680:c0:m2
def add_attributes(self, data, type):
for attr, ancestry in type.attributes():<EOL><INDENT>name = '<STR_LIT>' % attr.name<EOL>value = attr.get_default()<EOL>setattr(data, name, value)<EOL><DEDENT>
add required attributes
f9680:c0:m3
def skip_child(self, child, ancestry):
if child.any():<EOL><INDENT>return True<EOL><DEDENT>return any(x.choice() for x in ancestry)<EOL>
get whether or not to skip the specified child
f9680:c0:m4
def ordering(self, type):
result = []<EOL>for child, ancestry in type.resolve():<EOL><INDENT>name = child.name<EOL>if child.name is None:<EOL><INDENT>continue<EOL><DEDENT>if child.isattr():<EOL><INDENT>name = '<STR_LIT>' % child.name<EOL><DEDENT>result.append(name)<EOL><DEDENT>return result<EOL>
get the ordering
f9680:c0:m5
def cast(self, content):
aty = content.aty[<NUM_LIT:1>]<EOL>resolved = content.type.resolve()<EOL>array = Factory.object(resolved.name)<EOL>array.item = []<EOL>query = TypeQuery(aty)<EOL>ref = query.execute(self.schema)<EOL>if ref is None:<EOL><INDENT>raise TypeNotFound(qref)<EOL><DEDENT>for x in content.value:<EOL><INDENT>if isinstance(x, (list, tuple)):<EOL><INDENT>array.item.append(x)<EOL>continue<EOL><DEDENT>if isinstance(x, Object):<EOL><INDENT>md = x.__metadata__<EOL>md.sxtype = ref<EOL>array.item.append(x)<EOL>continue<EOL><DEDENT>if isinstance(x, dict):<EOL><INDENT>x = Factory.object(ref.name, x)<EOL>md = x.__metadata__<EOL>md.sxtype = ref<EOL>array.item.append(x)<EOL>continue<EOL><DEDENT>x = Factory.property(ref.name, x)<EOL>md = x.__metadata__<EOL>md.sxtype = ref<EOL>array.item.append(x)<EOL><DEDENT>content.value = array<EOL>return self<EOL>
Cast the I{untyped} list items found in content I{value}. Each items contained in the list is checked for XSD type information. Items (values) that are I{untyped}, are replaced with suds objects and type I{metadata} is added. @param content: The content holding the collection. @type content: L{Content} @return: self @rtype: L{Encoded}
f9681:c0:m3
def __init__(self, cls):
self.cls = cls<EOL>
@param cls: A class object. @type cls: I{classobj}
f9682:c0:m0
def __init__(self, marshaller):
self.default = PrimativeAppender(marshaller)<EOL>self.appenders = (<EOL>(Matcher(None),<EOL>NoneAppender(marshaller)),<EOL>(Matcher(null),<EOL>NoneAppender(marshaller)),<EOL>(Matcher(Property),<EOL>PropertyAppender(marshaller)),<EOL>(Matcher(Object),<EOL>ObjectAppender(marshaller)),<EOL>(Matcher(Element),<EOL>ElementAppender(marshaller)),<EOL>(Matcher(Text),<EOL>TextAppender(marshaller)),<EOL>(Matcher(list),<EOL>ListAppender(marshaller)),<EOL>(Matcher(tuple),<EOL>ListAppender(marshaller)),<EOL>(Matcher(dict),<EOL>DictAppender(marshaller)),<EOL>)<EOL>
@param marshaller: A marshaller. @type marshaller: L{suds.mx.core.Core}
f9682:c1:m0
def append(self, parent, content):
appender = self.default<EOL>for a in self.appenders:<EOL><INDENT>if a[<NUM_LIT:0>] == content.value:<EOL><INDENT>appender = a[<NUM_LIT:1>]<EOL>break<EOL><DEDENT><DEDENT>appender.append(parent, content)<EOL>
Select an appender and append the content to parent. @param parent: A parent node. @type parent: L{Element} @param content: The content to append. @type content: L{Content}
f9682:c1:m1
def __init__(self, marshaller):
self.marshaller = marshaller<EOL>
@param marshaller: A marshaller. @type marshaller: L{suds.mx.core.Core}
f9682:c2:m0
def node(self, content):
return self.marshaller.node(content)<EOL>
Create and return an XML node that is qualified using the I{type}. Also, make sure all referenced namespace prefixes are declared. @param content: The content for which proccessing has ended. @type content: L{Object} @return: A new node. @rtype: L{Element}
f9682:c2:m1
def setnil(self, node, content):
self.marshaller.setnil(node, content)<EOL>
Set the value of the I{node} to nill. @param node: A I{nil} node. @type node: L{Element} @param content: The content for which proccessing has ended. @type content: L{Object}
f9682:c2:m2
def setdefault(self, node, content):
return self.marshaller.setdefault(node, content)<EOL>
Set the value of the I{node} to a default value. @param node: A I{nil} node. @type node: L{Element} @param content: The content for which proccessing has ended. @type content: L{Object} @return: The default.
f9682:c2:m3