signature
stringlengths 8
3.44k
| body
stringlengths 0
1.41M
| docstring
stringlengths 1
122k
| id
stringlengths 5
17
|
|---|---|---|---|
def optional(self, content):
|
return self.marshaller.optional(content)<EOL>
|
Get whether the specified content is optional.
@param content: The content which to check.
@type content: L{Content}
|
f9682:c2:m4
|
def suspend(self, content):
|
self.marshaller.suspend(content)<EOL>
|
Notify I{marshaller} that appending this content has suspended.
@param content: The content for which proccessing has been suspended.
@type content: L{Object}
|
f9682:c2:m5
|
def resume(self, content):
|
self.marshaller.resume(content)<EOL>
|
Notify I{marshaller} that appending this content has resumed.
@param content: The content for which proccessing has been resumed.
@type content: L{Object}
|
f9682:c2:m6
|
def append(self, parent, content):
|
self.marshaller.append(parent, content)<EOL>
|
Append the specified L{content} to the I{parent}.
@param content: The content to append.
@type content: L{Object}
|
f9682:c2:m7
|
def __init__(self, schema, xstq=True):
|
Core.__init__(self)<EOL>self.schema = schema<EOL>self.xstq = xstq<EOL>self.resolver = GraphResolver(self.schema)<EOL>
|
@param schema: A schema object
@type schema: L{xsd.schema.Schema}
@param xstq: The B{x}ml B{s}chema B{t}ype B{q}ualified flag indicates
that the I{xsi:type} attribute values should be qualified by
namespace.
@type xstq: bool
|
f9683:c0:m0
|
def skip(self, content):
|
if self.optional(content):<EOL><INDENT>v = content.value<EOL>if v is None:<EOL><INDENT>return True<EOL><DEDENT>if isinstance(v, (list, tuple)) and len(v) == <NUM_LIT:0>:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>return False<EOL>
|
Get whether to skip this I{content}.
Should be skipped when the content is optional
and either the value=None or the value is an empty list.
@param content: The content to skip.
@type content: L{Object}
@return: True if content is to be skipped.
@rtype: bool
|
f9683:c0:m11
|
def translate(self, content):
|
v = content.value<EOL>if v is None:<EOL><INDENT>return<EOL><DEDENT>if isinstance(v, dict):<EOL><INDENT>cls = content.real.name<EOL>content.value = Factory.object(cls, v)<EOL>md = content.value.__metadata__<EOL>md.sxtype = content.type<EOL>return<EOL><DEDENT>v = content.real.translate(v, False)<EOL>content.value = v<EOL>return self<EOL>
|
Translate using the XSD type information.
Python I{dict} is translated to a suds object. Most
importantly, primative values are translated from python
types to XML types using the XSD type.
@param content: The content to translate.
@type content: L{Object}
@return: self
@rtype: L{Typed}
|
f9683:c0:m12
|
def sort(self, content):
|
v = content.value<EOL>if isinstance(v, Object):<EOL><INDENT>md = v.__metadata__<EOL>md.ordering = self.ordering(content.real)<EOL><DEDENT>return self<EOL>
|
Sort suds object attributes based on ordering defined
in the XSD type information.
@param content: The content to sort.
@type content: L{Object}
@return: self
@rtype: L{Typed}
|
f9683:c0:m13
|
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 attribute ordering defined in the specified
XSD type information.
@param type: An XSD type object.
@type type: SchemaObject
@return: An ordered list of attribute names.
@rtype: list
|
f9683:c0:m14
|
def process(self, value, tag=None):
|
content = Content(tag=tag, value=value)<EOL>result = Core.process(self, content)<EOL>return result<EOL>
|
Process (marshal) the tag with the specified value using the
optional type information.
@param value: The value (content) of the XML node.
@type value: (L{Object}|any)
@param tag: The (optional) tag name for the value. The default is
value.__class__.__name__
@type tag: str
@return: An xml node.
@rtype: L{Element}
|
f9684:c0:m0
|
@classmethod<EOL><INDENT>def auto(cls, node, value=None):<DEDENT>
|
if value is None:<EOL><INDENT>value = node.getText()<EOL><DEDENT>if isinstance(value, Object):<EOL><INDENT>known = cls.known(value)<EOL>if known.name is None:<EOL><INDENT>return node<EOL><DEDENT>tm = (known.name, known.namespace())<EOL><DEDENT>else:<EOL><INDENT>tm = cls.types.get(value.__class__, cls.types.get(str))<EOL><DEDENT>cls.manual(node, *tm)<EOL>return node<EOL>
|
Automatically set the node's xsi:type attribute based on either
I{value}'s class or the class of the node's text. When I{value} is an
unmapped class, the default type (xs:any) is set.
@param node: An XML node
@type node: L{sax.element.Element}
@param value: An object that is or would be the node's text.
@type value: I{any}
@return: The specified node.
@rtype: L{sax.element.Element}
|
f9685:c0:m0
|
@classmethod<EOL><INDENT>def manual(cls, node, tval, ns=None):<DEDENT>
|
xta = '<STR_LIT::>'.join((NS.xsins[<NUM_LIT:0>], '<STR_LIT:type>'))<EOL>node.addPrefix(NS.xsins[<NUM_LIT:0>], NS.xsins[<NUM_LIT:1>])<EOL>if ns is None:<EOL><INDENT>node.set(xta, tval)<EOL><DEDENT>else:<EOL><INDENT>ns = cls.genprefix(node, ns)<EOL>qname = '<STR_LIT::>'.join((ns[<NUM_LIT:0>], tval))<EOL>node.set(xta, qname)<EOL>node.addPrefix(ns[<NUM_LIT:0>], ns[<NUM_LIT:1>])<EOL><DEDENT>return node<EOL>
|
Set the node's xsi:type attribute based on either I{value}'s
class or the class of the node's text. Then adds the referenced
prefix(s) to the node's prefix mapping.
@param node: An XML node
@type node: L{sax.element.Element}
@param tval: The name of the schema type.
@type tval: str
@param ns: The XML namespace of I{tval}.
@type ns: (prefix, uri)
@return: The specified node.
@rtype: L{sax.element.Element}
|
f9685:c0:m1
|
@classmethod<EOL><INDENT>def genprefix(cls, node, ns):<DEDENT>
|
for n in range(<NUM_LIT:1>, <NUM_LIT>):<EOL><INDENT>p = '<STR_LIT>' % n<EOL>u = node.resolvePrefix(p, default=None)<EOL>if u is None or u == ns[<NUM_LIT:1>]:<EOL><INDENT>return (p, ns[<NUM_LIT:1>])<EOL><DEDENT><DEDENT>raise Exception('<STR_LIT>')<EOL>
|
Generate a prefix.
@param node: An XML node on which the prefix will be used.
@type node: L{sax.element.Element}
@param ns: A namespace needing an unique prefix.
@type ns: (prefix, uri)
@return: The I{ns} with a new prefix.
|
f9685:c0:m2
|
def __init__(self, tag=None, value=None, **kwargs):
|
Object.__init__(self)<EOL>self.tag = tag<EOL>self.value = value<EOL>for k, v in kwargs.items():<EOL><INDENT>setattr(self, k, v)<EOL><DEDENT>
|
@param tag: The content tag.
@type tag: str
@param value: The content's value.
@type value: I{any}
|
f9686:c0:m0
|
def process(self, content):
|
log.debug('<STR_LIT>', content)<EOL>self.reset()<EOL>if content.tag is None:<EOL><INDENT>content.tag = content.value.__class__.__name__<EOL><DEDENT>document = Document()<EOL>if isinstance(content.value, Property):<EOL><INDENT>root = self.node(content) <EOL>self.append(document, content)<EOL><DEDENT>else:<EOL><INDENT>self.append(document, content)<EOL><DEDENT>return document.root()<EOL>
|
Process (marshal) the tag with the specified value using the
optional type information.
@param content: The content to process.
@type content: L{Object}
|
f9687:c0:m1
|
def append(self, parent, content):
|
log.debug('<STR_LIT>', parent, content)<EOL>if self.start(content):<EOL><INDENT>self.appender.append(parent, content)<EOL>self.end(parent, content)<EOL><DEDENT>
|
Append the specified L{content} to the I{parent}.
@param parent: The parent node to append to.
@type parent: L{Element}
@param content: The content to append.
@type content: L{Object}
|
f9687:c0:m2
|
def reset(self):
|
pass<EOL>
|
Reset the marshaller.
|
f9687:c0:m3
|
def node(self, content):
|
return Element(content.tag)<EOL>
|
Create and return an XML node.
@param content: The content for which proccessing has been suspended.
@type content: L{Object}
@return: An element.
@rtype: L{Element}
|
f9687:c0:m4
|
def start(self, content):
|
return True<EOL>
|
Appending this content has started.
@param content: The content for which proccessing has started.
@type content: L{Content}
@return: True to continue appending
@rtype: boolean
|
f9687:c0:m5
|
def suspend(self, content):
|
pass<EOL>
|
Appending this content has suspended.
@param content: The content for which proccessing has been suspended.
@type content: L{Content}
|
f9687:c0:m6
|
def resume(self, content):
|
pass<EOL>
|
Appending this content has resumed.
@param content: The content for which proccessing has been resumed.
@type content: L{Content}
|
f9687:c0:m7
|
def end(self, parent, content):
|
pass<EOL>
|
Appending this content has ended.
@param parent: The parent node ending.
@type parent: L{Element}
@param content: The content for which proccessing has ended.
@type content: L{Content}
|
f9687:c0:m8
|
def setnil(self, node, content):
|
pass<EOL>
|
Set the value of the I{node} to nill.
@param node: A I{nil} node.
@type node: L{Element}
@param content: The content to set nil.
@type content: L{Content}
|
f9687:c0:m9
|
def setdefault(self, node, content):
|
pass<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 to set the default value.
@type content: L{Content}
@return: The default.
|
f9687:c0:m10
|
def optional(self, content):
|
return False<EOL>
|
Get whether the specified content is optional.
@param content: The content which to check.
@type content: L{Content}
|
f9687:c0:m11
|
def open(self, url):
|
protocol, location = self.split(url)<EOL>if protocol == self.protocol:<EOL><INDENT>return self.find(location)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>
|
Open a document at the specified url.
@param url: A document URL.
@type url: str
@return: A file pointer to the document.
@rtype: StringIO
|
f9689:c0:m0
|
def find(self, location):
|
try:<EOL><INDENT>content = self.store[location]<EOL>return StringIO(content)<EOL><DEDENT>except:<EOL><INDENT>reason = '<STR_LIT>' % location<EOL>raise Exception(reason)<EOL><DEDENT>
|
Find the specified location in the store.
@param location: The I{location} part of a URL.
@type location: str
@return: An input stream to the document.
@rtype: StringIO
|
f9689:c0:m1
|
def split(self, url):
|
parts = url.split('<STR_LIT>', <NUM_LIT:1>)<EOL>if len(parts) == <NUM_LIT:2>:<EOL><INDENT>return parts<EOL><DEDENT>else:<EOL><INDENT>return (None, url)<EOL><DEDENT>
|
Split the url into I{protocol} and I{location}
@param url: A URL.
@param url: str
@return: (I{url}, I{location})
@rtype: tuple
|
f9689:c0:m2
|
def items(sobject):
|
for item in sobject:<EOL><INDENT>yield item<EOL><DEDENT>
|
Extract the I{items} from a suds object much like the
items() method works on I{dict}.
@param sobject: A suds object
@type sobject: L{Object}
@return: A list of items contained in I{sobject}.
@rtype: [(key, value),...]
|
f9690:m0
|
def asdict(sobject):
|
return dict(items(sobject))<EOL>
|
Convert a sudsobject into a dictionary.
@param sobject: A suds object
@type sobject: L{Object}
@return: A python dictionary containing the
items contained in I{sobject}.
@rtype: dict
|
f9690:m1
|
def merge(a, b):
|
for item in a:<EOL><INDENT>setattr(b, item[<NUM_LIT:0>], item[<NUM_LIT:1>])<EOL>b.__metadata__ = b.__metadata__<EOL><DEDENT>return b<EOL>
|
Merge all attributes and metadata from I{a} to I{b}.
@param a: A I{source} object
@type a: L{Object}
@param b: A I{destination} object
@type b: L{Object}
|
f9690:m2
|
def footprint(sobject):
|
n = <NUM_LIT:0><EOL>for a in sobject.__keylist__:<EOL><INDENT>v = getattr(sobject, a)<EOL>if v is None:<EOL><INDENT>continue<EOL><DEDENT>if isinstance(v, Object):<EOL><INDENT>n += footprint(v)<EOL>continue<EOL><DEDENT>if hasattr(v, '<STR_LIT>'):<EOL><INDENT>if len(v):<EOL><INDENT>n += <NUM_LIT:1><EOL><DEDENT>continue<EOL><DEDENT>n += <NUM_LIT:1><EOL><DEDENT>return n<EOL>
|
Get the I{virtual footprint} of the object.
This is really a count of the attributes in the branch with a significant
value.
@param sobject: A suds object.
@type sobject: L{Object}
@return: The branch footprint.
@rtype: int
|
f9690:m3
|
def tostr(self, object, indent=-<NUM_LIT:2>):
|
history = []<EOL>return self.process(object, history, indent)<EOL>
|
get s string representation of object
|
f9690:c6:m1
|
def process(self, object, h, n=<NUM_LIT:0>, nl=False):
|
if object is None:<EOL><INDENT>return '<STR_LIT:None>'<EOL><DEDENT>if isinstance(object, Object):<EOL><INDENT>if len(object) == <NUM_LIT:0>:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>return self.print_object(object, h, n+<NUM_LIT:2>, nl)<EOL><DEDENT><DEDENT>if isinstance(object, dict):<EOL><INDENT>if len(object) == <NUM_LIT:0>:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>return self.print_dictionary(object, h, n+<NUM_LIT:2>, nl)<EOL><DEDENT><DEDENT>if isinstance(object, (list, tuple)):<EOL><INDENT>if len(object) == <NUM_LIT:0>:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>return self.print_collection(object, h, n+<NUM_LIT:2>)<EOL><DEDENT><DEDENT>if isinstance(object, basestring):<EOL><INDENT>return '<STR_LIT>' % tostr(object)<EOL><DEDENT>return '<STR_LIT:%s>' % tostr(object)<EOL>
|
print object using the specified indent (n) and newline (nl).
|
f9690:c6:m2
|
def print_object(self, d, h, n, nl=False):
|
s = []<EOL>cls = d.__class__<EOL>md = d.__metadata__<EOL>if d in h:<EOL><INDENT>s.append('<STR_LIT:(>')<EOL>s.append(cls.__name__)<EOL>s.append('<STR_LIT:)>')<EOL>s.append('<STR_LIT>')<EOL>return '<STR_LIT>'.join(s)<EOL><DEDENT>h.append(d)<EOL>if nl:<EOL><INDENT>s.append('<STR_LIT:\n>')<EOL>s.append(self.indent(n))<EOL><DEDENT>if cls != Object:<EOL><INDENT>s.append('<STR_LIT:(>')<EOL>if isinstance(d, Facade):<EOL><INDENT>s.append(md.facade)<EOL><DEDENT>else:<EOL><INDENT>s.append(cls.__name__)<EOL><DEDENT>s.append('<STR_LIT:)>')<EOL><DEDENT>s.append('<STR_LIT:{>')<EOL>for item in d:<EOL><INDENT>if self.exclude(d, item):<EOL><INDENT>continue<EOL><DEDENT>item = self.unwrap(d, item)<EOL>s.append('<STR_LIT:\n>')<EOL>s.append(self.indent(n+<NUM_LIT:1>))<EOL>if isinstance(item[<NUM_LIT:1>], (list, tuple)):<EOL><INDENT>s.append(item[<NUM_LIT:0>])<EOL>s.append('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>s.append(item[<NUM_LIT:0>])<EOL><DEDENT>s.append('<STR_LIT>')<EOL>s.append(self.process(item[<NUM_LIT:1>], h, n, True))<EOL><DEDENT>s.append('<STR_LIT:\n>')<EOL>s.append(self.indent(n))<EOL>s.append('<STR_LIT:}>')<EOL>h.pop()<EOL>return '<STR_LIT>'.join(s)<EOL>
|
print complex using the specified indent (n) and newline (nl).
|
f9690:c6:m3
|
def print_dictionary(self, d, h, n, nl=False):
|
if d in h:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>h.append(d)<EOL>s = []<EOL>if nl:<EOL><INDENT>s.append('<STR_LIT:\n>')<EOL>s.append(self.indent(n))<EOL><DEDENT>s.append('<STR_LIT:{>')<EOL>for item in d.items():<EOL><INDENT>s.append('<STR_LIT:\n>')<EOL>s.append(self.indent(n+<NUM_LIT:1>))<EOL>if isinstance(item[<NUM_LIT:1>], (list, tuple)):<EOL><INDENT>s.append(tostr(item[<NUM_LIT:0>]))<EOL>s.append('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>s.append(tostr(item[<NUM_LIT:0>]))<EOL><DEDENT>s.append('<STR_LIT>')<EOL>s.append(self.process(item[<NUM_LIT:1>], h, n, True))<EOL><DEDENT>s.append('<STR_LIT:\n>')<EOL>s.append(self.indent(n))<EOL>s.append('<STR_LIT:}>')<EOL>h.pop()<EOL>return '<STR_LIT>'.join(s)<EOL>
|
print complex using the specified indent (n) and newline (nl).
|
f9690:c6:m4
|
def print_collection(self, c, h, n):
|
if c in h:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>h.append(c)<EOL>s = []<EOL>for item in c:<EOL><INDENT>s.append('<STR_LIT:\n>')<EOL>s.append(self.indent(n))<EOL>s.append(self.process(item, h, n-<NUM_LIT:2>))<EOL>s.append('<STR_LIT:U+002C>')<EOL><DEDENT>h.pop()<EOL>return '<STR_LIT>'.join(s)<EOL>
|
print collection using the specified indent (n) and newline (nl).
|
f9690:c6:m5
|
def unwrap(self, d, item):
|
nopt = lambda x: x<EOL>try:<EOL><INDENT>md = d.__metadata__<EOL>pmd = getattr(md, '<STR_LIT>', None)<EOL>if pmd is None:<EOL><INDENT>return item<EOL><DEDENT>wrappers = getattr(pmd, '<STR_LIT>', {})<EOL>fn = wrappers.get(item[<NUM_LIT:0>], nopt)<EOL>return (item[<NUM_LIT:0>], fn(item[<NUM_LIT:1>]))<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>return item<EOL>
|
translate (unwrap) using an optional wrapper function
|
f9690:c6:m6
|
def exclude(self, d, item):
|
try:<EOL><INDENT>md = d.__metadata__<EOL>pmd = getattr(md, '<STR_LIT>', None)<EOL>if pmd is None:<EOL><INDENT>return False<EOL><DEDENT>excludes = getattr(pmd, '<STR_LIT>', [])<EOL>return item[<NUM_LIT:0>] in excludes<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT>return False<EOL>
|
check metadata for excluded items
|
f9690:c6:m7
|
@classmethod<EOL><INDENT>def items(cls, sobject):<DEDENT>
|
return sudsobject.items(sobject)<EOL>
|
Extract the I{items} from a suds object much like the
items() method works on I{dict}.
@param sobject: A suds object
@type sobject: L{Object}
@return: A list of items contained in I{sobject}.
@rtype: [(key, value),...]
|
f9692:c0:m0
|
@classmethod<EOL><INDENT>def dict(cls, sobject):<DEDENT>
|
return sudsobject.asdict(sobject)<EOL>
|
Convert a sudsobject into a dictionary.
@param sobject: A suds object
@type sobject: L{Object}
@return: A python dictionary containing the
items contained in I{sobject}.
@rtype: dict
|
f9692:c0:m1
|
@classmethod<EOL><INDENT>def metadata(cls, sobject):<DEDENT>
|
return sobject.__metadata__<EOL>
|
Extract the metadata from a suds object.
@param sobject: A suds object
@type sobject: L{Object}
@return: The object's metadata
@rtype: L{sudsobject.Metadata}
|
f9692:c0:m2
|
def __init__(self, url, **kwargs):
|
options = Options()<EOL>options.transport = HttpAuthenticated()<EOL>self.options = options<EOL>self.options.location = url<EOL>options.cache = ObjectCache(days=<NUM_LIT:1>)<EOL>self.set_options(**kwargs)<EOL>reader = DefinitionsReader(options, Definitions)<EOL>self.wsdl = reader.open(url)<EOL>plugins = PluginContainer(options.plugins)<EOL>plugins.init.initialized(wsdl=self.wsdl)<EOL>self.factory = Factory(self.wsdl)<EOL>self.service = ServiceSelector(self, self.wsdl.services)<EOL>self.sd = []<EOL>for s in self.wsdl.services:<EOL><INDENT>sd = ServiceDefinition(self.wsdl, s)<EOL>self.sd.append(sd)<EOL><DEDENT>self.messages = dict(tx=None, rx=None)<EOL>
|
@param url: The URL for the WSDL.
@type url: str
@param kwargs: keyword arguments.
@see: L{Options}
|
f9692:c0:m3
|
def set_options(self, **kwargs):
|
p = Unskin(self.options)<EOL>p.update(kwargs)<EOL>
|
Set options.
@param kwargs: keyword arguments.
@see: L{Options}
|
f9692:c0:m4
|
def add_prefix(self, prefix, uri):
|
root = self.wsdl.root<EOL>mapped = root.resolvePrefix(prefix, None)<EOL>if mapped is None:<EOL><INDENT>root.addPrefix(prefix, uri)<EOL>return<EOL><DEDENT>if mapped[<NUM_LIT:1>] != uri:<EOL><INDENT>raise Exception('<STR_LIT>' % (prefix, mapped))<EOL><DEDENT>
|
Add I{static} mapping of an XML namespace prefix to a namespace.
This is useful for cases when a wsdl and referenced schemas make heavy
use of namespaces and those namespaces are subject to changed.
@param prefix: An XML namespace prefix.
@type prefix: str
@param uri: An XML namespace URI.
@type uri: str
@raise Exception: when prefix is already mapped.
|
f9692:c0:m5
|
def last_sent(self):
|
return self.messages.get('<STR_LIT>')<EOL>
|
Get last sent I{soap} message.
@return: The last sent I{soap} message.
@rtype: L{Document}
|
f9692:c0:m6
|
def last_received(self):
|
return self.messages.get('<STR_LIT>')<EOL>
|
Get last received I{soap} message.
@return: The last received I{soap} message.
@rtype: L{Document}
|
f9692:c0:m7
|
def clone(self):
|
class Uninitialized(Client):<EOL><INDENT>def __init__(self):<EOL><INDENT>pass<EOL><DEDENT><DEDENT>clone = Uninitialized()<EOL>clone.options = Options()<EOL>cp = Unskin(clone.options)<EOL>mp = Unskin(self.options)<EOL>cp.update(deepcopy(mp))<EOL>clone.wsdl = self.wsdl<EOL>clone.factory = self.factory<EOL>clone.service = ServiceSelector(clone, self.wsdl.services)<EOL>clone.sd = self.sd<EOL>clone.messages = dict(tx=None, rx=None)<EOL>return clone<EOL>
|
Get a shallow clone of this object.
The clone only shares the WSDL. All other attributes are
unique to the cloned object including options.
@return: A shallow clone.
@rtype: L{Client}
|
f9692:c0:m8
|
def __init__(self, wsdl):
|
self.wsdl = wsdl<EOL>self.resolver = PathResolver(wsdl)<EOL>self.builder = Builder(self.resolver)<EOL>
|
@param wsdl: A schema object.
@type wsdl: L{wsdl.Definitions}
|
f9692:c1:m0
|
def create(self, name):
|
timer = metrics.Timer()<EOL>timer.start()<EOL>type = self.resolver.find(name)<EOL>if type is None:<EOL><INDENT>raise TypeNotFound(name)<EOL><DEDENT>if type.enum():<EOL><INDENT>result = InstFactory.object(name)<EOL>for e, a in type.children():<EOL><INDENT>setattr(result, e.name, e.name)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>result = self.builder.build(type)<EOL><DEDENT>except Exception as e:<EOL><INDENT>log.error("<STR_LIT>", name, exc_info=True)<EOL>raise BuildError(name, e)<EOL><DEDENT><DEDENT>timer.stop()<EOL>metrics.log.debug('<STR_LIT>', name, timer)<EOL>return result<EOL>
|
create a WSDL type by name
@param name: The name of a type defined in the WSDL.
@type name: str
@return: The requested object.
@rtype: L{Object}
|
f9692:c1:m1
|
def separator(self, ps):
|
self.resolver = PathResolver(self.wsdl, ps)<EOL>
|
Set the path separator.
@param ps: The new path separator.
@type ps: char
|
f9692:c1:m2
|
def __init__(self, client, services):
|
self.__client = client<EOL>self.__services = services<EOL>
|
@param client: A suds client.
@type client: L{Client}
@param services: A list of I{wsdl} services.
@type services: list
|
f9692:c2:m0
|
def __getattr__(self, name):
|
default = self.__ds()<EOL>if default is None:<EOL><INDENT>port = self.__find(<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>port = default<EOL><DEDENT>return getattr(port, name)<EOL>
|
Request to access an attribute is forwarded to the
L{PortSelector} for either the I{first} service or the
I{default} service (when specified).
@param name: The name of a method.
@type name: str
@return: A L{PortSelector}.
@rtype: L{PortSelector}.
|
f9692:c2:m1
|
def __getitem__(self, name):
|
if len(self.__services) == <NUM_LIT:1>:<EOL><INDENT>port = self.__find(<NUM_LIT:0>)<EOL>return port[name]<EOL><DEDENT>default = self.__ds()<EOL>if default is not None:<EOL><INDENT>port = default<EOL>return port[name]<EOL><DEDENT>return self.__find(name)<EOL>
|
Provides selection of the I{service} by name (string) or
index (integer). In cases where only (1) service is defined
or a I{default} has been specified, the request is forwarded
to the L{PortSelector}.
@param name: The name (or index) of a service.
@type name: (int|str)
@return: A L{PortSelector} for the specified service.
@rtype: L{PortSelector}.
|
f9692:c2:m2
|
def __find(self, name):
|
service = None<EOL>if not len(self.__services):<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>if isinstance(name, int):<EOL><INDENT>try:<EOL><INDENT>service = self.__services[name]<EOL>name = service.name<EOL><DEDENT>except IndexError:<EOL><INDENT>raise ServiceNotFound('<STR_LIT>' % name)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for s in self.__services:<EOL><INDENT>if name == s.name:<EOL><INDENT>service = s<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if service is None:<EOL><INDENT>raise ServiceNotFound(name)<EOL><DEDENT>return PortSelector(self.__client, service.ports, name)<EOL>
|
Find a I{service} by name (string) or index (integer).
@param name: The name (or index) of a service.
@type name: (int|str)
@return: A L{PortSelector} for the found service.
@rtype: L{PortSelector}.
|
f9692:c2:m3
|
def __ds(self):
|
ds = self.__client.options.service<EOL>if ds is None:<EOL><INDENT>return None<EOL><DEDENT>else:<EOL><INDENT>return self.__find(ds)<EOL><DEDENT>
|
Get the I{default} service if defined in the I{options}.
@return: A L{PortSelector} for the I{default} service.
@rtype: L{PortSelector}.
|
f9692:c2:m4
|
def __init__(self, client, ports, qn):
|
self.__client = client<EOL>self.__ports = ports<EOL>self.__qn = qn<EOL>
|
@param client: A suds client.
@type client: L{Client}
@param ports: A list of I{service} ports.
@type ports: list
@param qn: The name of the service.
@type qn: str
|
f9692:c3:m0
|
def __getattr__(self, name):
|
default = self.__dp()<EOL>if default is None:<EOL><INDENT>m = self.__find(<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>m = default<EOL><DEDENT>return getattr(m, name)<EOL>
|
Request to access an attribute is forwarded to the
L{MethodSelector} for either the I{first} port or the
I{default} port (when specified).
@param name: The name of a method.
@type name: str
@return: A L{MethodSelector}.
@rtype: L{MethodSelector}.
|
f9692:c3:m1
|
def __getitem__(self, name):
|
default = self.__dp()<EOL>if default is None:<EOL><INDENT>return self.__find(name)<EOL><DEDENT>else:<EOL><INDENT>return default<EOL><DEDENT>
|
Provides selection of the I{port} by name (string) or
index (integer). In cases where only (1) port is defined
or a I{default} has been specified, the request is forwarded
to the L{MethodSelector}.
@param name: The name (or index) of a port.
@type name: (int|str)
@return: A L{MethodSelector} for the specified port.
@rtype: L{MethodSelector}.
|
f9692:c3:m2
|
def __find(self, name):
|
port = None<EOL>if not len(self.__ports):<EOL><INDENT>raise Exception('<STR_LIT>' % self.__qn)<EOL><DEDENT>if isinstance(name, int):<EOL><INDENT>qn = '<STR_LIT>' % (self.__qn, name)<EOL>try:<EOL><INDENT>port = self.__ports[name]<EOL><DEDENT>except IndexError:<EOL><INDENT>raise PortNotFound(qn)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>qn = '<STR_LIT:.>'.join((self.__qn, name))<EOL>for p in self.__ports:<EOL><INDENT>if name == p.name:<EOL><INDENT>port = p<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if port is None:<EOL><INDENT>raise PortNotFound(qn)<EOL><DEDENT>qn = '<STR_LIT:.>'.join((self.__qn, port.name))<EOL>return MethodSelector(self.__client, port.methods, qn)<EOL>
|
Find a I{port} by name (string) or index (integer).
@param name: The name (or index) of a port.
@type name: (int|str)
@return: A L{MethodSelector} for the found port.
@rtype: L{MethodSelector}.
|
f9692:c3:m3
|
def __dp(self):
|
dp = self.__client.options.port<EOL>if dp is None:<EOL><INDENT>return None<EOL><DEDENT>else:<EOL><INDENT>return self.__find(dp)<EOL><DEDENT>
|
Get the I{default} port if defined in the I{options}.
@return: A L{MethodSelector} for the I{default} port.
@rtype: L{MethodSelector}.
|
f9692:c3:m4
|
def __init__(self, client, methods, qn):
|
self.__client = client<EOL>self.__methods = methods<EOL>self.__qn = qn<EOL>
|
@param client: A suds client.
@type client: L{Client}
@param methods: A dictionary of methods.
@type methods: dict
@param qn: The I{qualified} name of the port.
@type qn: str
|
f9692:c4:m0
|
def __getattr__(self, name):
|
return self[name]<EOL>
|
Get a method by name and return it in an I{execution wrapper}.
@param name: The name of a method.
@type name: str
@return: An I{execution wrapper} for the specified method name.
@rtype: L{Method}
|
f9692:c4:m1
|
def __getitem__(self, name):
|
m = self.__methods.get(name)<EOL>if m is None:<EOL><INDENT>qn = '<STR_LIT:.>'.join((self.__qn, name))<EOL>raise MethodNotFound(qn)<EOL><DEDENT>return Method(self.__client, m)<EOL>
|
Get a method by name and return it in an I{execution wrapper}.
@param name: The name of a method.
@type name: str
@return: An I{execution wrapper} for the specified method name.
@rtype: L{Method}
|
f9692:c4:m2
|
def __init__(self, client, method):
|
self.client = client<EOL>self.method = method<EOL>
|
@param client: A client object.
@type client: L{Client}
@param method: A I{raw} method.
@type I{raw} Method.
|
f9692:c5:m0
|
def __call__(self, *args, **kwargs):
|
clientclass = self.clientclass(kwargs)<EOL>client = clientclass(self.client, self.method)<EOL>if not self.faults():<EOL><INDENT>try:<EOL><INDENT>return client.invoke(args, kwargs)<EOL><DEDENT>except WebFault as e:<EOL><INDENT>return (<NUM_LIT>, e)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return client.invoke(args, kwargs)<EOL><DEDENT>
|
Invoke the method.
|
f9692:c5:m1
|
def faults(self):
|
return self.client.options.faults<EOL>
|
get faults option
|
f9692:c5:m2
|
def clientclass(self, kwargs):
|
if SimClient.simulation(kwargs):<EOL><INDENT>return SimClient<EOL><DEDENT>else:<EOL><INDENT>return SoapClient<EOL><DEDENT>
|
get soap client class
|
f9692:c5:m3
|
def __init__(self, client, method):
|
self.client = client<EOL>self.method = method<EOL>self.options = client.options<EOL>self.cookiejar = CookieJar()<EOL>
|
@param client: A suds client.
@type client: L{Client}
@param method: A target method.
@type method: L{Method}
|
f9692:c6:m0
|
def invoke(self, args, kwargs):
|
timer = metrics.Timer()<EOL>timer.start()<EOL>result = None<EOL>binding = self.method.binding.input<EOL>soapenv = binding.get_message(self.method, args, kwargs)<EOL>timer.stop()<EOL>metrics.log.debug("<STR_LIT>",<EOL>self.method.name,<EOL>timer)<EOL>timer.start()<EOL>result = self.send(soapenv)<EOL>timer.stop()<EOL>metrics.log.debug("<STR_LIT>",<EOL>self.method.name,<EOL>timer)<EOL>return result<EOL>
|
Send the required soap message to invoke the specified method
@param args: A list of args for the method invoked.
@type args: list
@param kwargs: Named (keyword) args for the method invoked.
@type kwargs: dict
@return: The result of the method invocation.
@rtype: I{builtin}|I{subclass of} L{Object}
|
f9692:c6:m1
|
def send(self, soapenv):
|
result = None<EOL>location = self.location()<EOL>binding = self.method.binding.input<EOL>transport = self.options.transport<EOL>retxml = self.options.retxml<EOL>prettyxml = self.options.prettyxml<EOL>log.debug('<STR_LIT>', location, soapenv)<EOL>try:<EOL><INDENT>self.last_sent(soapenv)<EOL>plugins = PluginContainer(self.options.plugins)<EOL>plugins.message.marshalled(envelope=soapenv.root())<EOL>if prettyxml:<EOL><INDENT>soapenv = soapenv.str()<EOL><DEDENT>else:<EOL><INDENT>soapenv = soapenv.plain()<EOL><DEDENT>soapenv = soapenv.encode('<STR_LIT:utf-8>')<EOL>plugins.message.sending(envelope=soapenv)<EOL>request = Request(location, soapenv)<EOL>request.headers = self.headers()<EOL>reply = transport.send(request)<EOL>ctx = plugins.message.received(reply=reply.message)<EOL>reply.message = ctx.reply<EOL>if retxml:<EOL><INDENT>result = reply.message<EOL><DEDENT>else:<EOL><INDENT>result = self.succeeded(binding, reply.message)<EOL><DEDENT><DEDENT>except TransportError as e:<EOL><INDENT>if e.httpcode in (<NUM_LIT>, <NUM_LIT>):<EOL><INDENT>result = None<EOL><DEDENT>else:<EOL><INDENT>log.error(self.last_sent())<EOL>result = self.failed(binding, e)<EOL><DEDENT><DEDENT>return result<EOL>
|
Send soap message.
@param soapenv: A soap envelope to send.
@type soapenv: L{Document}
@return: The reply to the sent message.
@rtype: I{builtin} or I{subclass of} L{Object}
|
f9692:c6:m2
|
def headers(self):
|
action = self.method.soap.action<EOL>result = {<EOL>'<STR_LIT:Content-Type>': '<STR_LIT>',<EOL>'<STR_LIT>': action<EOL>}<EOL>result.update(self.options.headers)<EOL>log.debug('<STR_LIT>', result)<EOL>return result<EOL>
|
Get http headers or the http/https request.
@return: A dictionary of header/values.
@rtype: dict
|
f9692:c6:m3
|
def succeeded(self, binding, reply):
|
log.debug('<STR_LIT>', reply)<EOL>plugins = PluginContainer(self.options.plugins)<EOL>if len(reply) > <NUM_LIT:0>:<EOL><INDENT>reply, result = binding.get_reply(self.method, reply)<EOL>self.last_received(reply)<EOL><DEDENT>else:<EOL><INDENT>result = None<EOL><DEDENT>ctx = plugins.message.unmarshalled(reply=result)<EOL>result = ctx.reply<EOL>if self.options.faults:<EOL><INDENT>return result<EOL><DEDENT>else:<EOL><INDENT>return (<NUM_LIT:200>, result)<EOL><DEDENT>
|
Request succeeded, process the reply
@param binding: The binding to be used to process the reply.
@type binding: L{bindings.binding.Binding}
@param reply: The raw reply text.
@type reply: str
@return: The method result.
@rtype: I{builtin}, L{Object}
@raise WebFault: On server.
|
f9692:c6:m4
|
def failed(self, binding, error):
|
status, reason = (error.httpcode, suds.tostr(error))<EOL>reply = error.fp.read()<EOL>log.debug('<STR_LIT>', reply)<EOL>if status == <NUM_LIT>:<EOL><INDENT>if len(reply) > <NUM_LIT:0>:<EOL><INDENT>r, p = binding.get_fault(reply)<EOL>self.last_received(r)<EOL>return (status, p)<EOL><DEDENT>else:<EOL><INDENT>return (status, None)<EOL><DEDENT><DEDENT>if self.options.faults:<EOL><INDENT>raise Exception((status, reason))<EOL><DEDENT>else:<EOL><INDENT>return (status, None)<EOL><DEDENT>
|
Request failed, process reply based on reason
@param binding: The binding to be used to process the reply.
@type binding: L{suds.bindings.binding.Binding}
@param error: The http error message
@type error: L{transport.TransportError}
|
f9692:c6:m5
|
@classmethod<EOL><INDENT>def simulation(cls, kwargs):<DEDENT>
|
return SimClient.injkey in kwargs.keys()<EOL>
|
get whether loopback has been specified in the I{kwargs}.
|
f9692:c7:m0
|
def invoke(self, args, kwargs):
|
simulation = kwargs[self.injkey]<EOL>msg = simulation.get('<STR_LIT>')<EOL>reply = simulation.get('<STR_LIT>')<EOL>fault = simulation.get('<STR_LIT>')<EOL>if msg is None:<EOL><INDENT>if reply is not None:<EOL><INDENT>return self.__reply(reply, args, kwargs)<EOL><DEDENT>if fault is not None:<EOL><INDENT>return self.__fault(fault)<EOL><DEDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>sax = Parser()<EOL>msg = sax.parse(string=msg)<EOL>return self.send(msg)<EOL>
|
Send the required soap message to invoke the specified method
@param args: A list of args for the method invoked.
@type args: list
@param kwargs: Named (keyword) args for the method invoked.
@type kwargs: dict
@return: The result of the method invocation.
@rtype: I{builtin} or I{subclass of} L{Object}
|
f9692:c7:m1
|
def __reply(self, reply, args, kwargs):
|
binding = self.method.binding.input<EOL>msg = binding.get_message(self.method, args, kwargs)<EOL>log.debug('<STR_LIT>', msg)<EOL>binding = self.method.binding.output<EOL>return self.succeeded(binding, reply)<EOL>
|
simulate the reply
|
f9692:c7:m2
|
def __fault(self, reply):
|
binding = self.method.binding.output<EOL>if self.options.faults:<EOL><INDENT>r, p = binding.get_fault(reply)<EOL>self.last_received(r)<EOL>return (<NUM_LIT>, p)<EOL><DEDENT>else:<EOL><INDENT>return (<NUM_LIT>, None)<EOL><DEDENT>
|
simulate the (fault) reply
|
f9692:c7:m3
|
def updated(self, properties, prev, next):
|
pass<EOL>
|
Notification that a values was updated and the linkage
between the I{properties} contained with I{prev} need to
be relinked to the L{Properties} contained within the
I{next} value.
|
f9693:c0:m0
|
def __init__(self, a, b):
|
pA = Endpoint(self, a)<EOL>pB = Endpoint(self, b)<EOL>self.endpoints = (pA, pB)<EOL>self.validate(a, b)<EOL>a.links.append(pB)<EOL>b.links.append(pA)<EOL>
|
@param a: Property (A) to link.
@type a: L{Property}
@param b: Property (B) to link.
@type b: L{Property}
|
f9693:c1:m0
|
def validate(self, pA, pB):
|
if pA in pB.links orpB in pA.links:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>dA = pA.domains()<EOL>dB = pB.domains()<EOL>for d in dA:<EOL><INDENT>if d in dB:<EOL><INDENT>raise Exception('<STR_LIT>' % d)<EOL><DEDENT><DEDENT>for d in dB:<EOL><INDENT>if d in dA:<EOL><INDENT>raise Exception('<STR_LIT>' % d)<EOL><DEDENT><DEDENT>kA = pA.keys()<EOL>kB = pB.keys()<EOL>for k in kA:<EOL><INDENT>if k in kB:<EOL><INDENT>raise Exception('<STR_LIT>' % k)<EOL><DEDENT><DEDENT>for k in kB:<EOL><INDENT>if k in kA:<EOL><INDENT>raise Exception('<STR_LIT>' % k)<EOL><DEDENT><DEDENT>return self<EOL>
|
Validate that the two properties may be linked.
@param pA: Endpoint (A) to link.
@type pA: L{Endpoint}
@param pB: Endpoint (B) to link.
@type pB: L{Endpoint}
@return: self
@rtype: L{Link}
|
f9693:c1:m1
|
def teardown(self):
|
pA, pB = self.endpoints<EOL>if pA in pB.links:<EOL><INDENT>pB.links.remove(pA)<EOL><DEDENT>if pB in pA.links:<EOL><INDENT>pA.links.remove(pB)<EOL><DEDENT>return self<EOL>
|
Teardown the link.
Removes endpoints from properties I{links} collection.
@return: self
@rtype: L{Link}
|
f9693:c1:m2
|
def __init__(self, name, classes, default, linker=AutoLinker()):
|
if not isinstance(classes, (list, tuple)):<EOL><INDENT>classes = (classes,)<EOL><DEDENT>self.name = name<EOL>self.classes = classes<EOL>self.default = default<EOL>self.linker = linker<EOL>
|
@param name: The property name.
@type name: str
@param classes: The (class) list of permitted values
@type classes: tuple
@param default: The default value.
@type default: any
|
f9693:c3:m0
|
def nvl(self, value=None):
|
if value is None:<EOL><INDENT>return self.default<EOL><DEDENT>else:<EOL><INDENT>return value<EOL><DEDENT>
|
Convert the I{value} into the default when I{None}.
@param value: The proposed value.
@type value: any
@return: The I{default} when I{value} is I{None}, else I{value}.
@rtype: any
|
f9693:c3:m1
|
def validate(self, value):
|
if value is None:<EOL><INDENT>return<EOL><DEDENT>if len(self.classes) and not isinstance(value, self.classes):<EOL><INDENT>msg = '<STR_LIT>' % (self.name, self.classes)<EOL>raise AttributeError(msg)<EOL><DEDENT>
|
Validate the I{value} is of the correct class.
@param value: The value to validate.
@type value: any
@raise AttributeError: When I{value} is invalid.
|
f9693:c3:m2
|
def __init__(self, domain, definitions, kwargs):
|
self.definitions = {}<EOL>for d in definitions:<EOL><INDENT>self.definitions[d.name] = d<EOL><DEDENT>self.domain = domain<EOL>self.links = []<EOL>self.defined = {}<EOL>self.modified = set()<EOL>self.prime()<EOL>self.update(kwargs)<EOL>
|
@param domain: The property domain name.
@type domain: str
@param definitions: A table of property definitions.
@type definitions: {name: L{Definition}}
@param kwargs: A list of property name/values to set.
@type kwargs: dict
|
f9693:c4:m0
|
def definition(self, name):
|
d = self.definitions.get(name)<EOL>if d is None:<EOL><INDENT>raise AttributeError(name)<EOL><DEDENT>return d<EOL>
|
Get the definition for the property I{name}.
@param name: The property I{name} to find the definition for.
@type name: str
@return: The property definition
@rtype: L{Definition}
@raise AttributeError: On not found.
|
f9693:c4:m1
|
def update(self, other):
|
if isinstance(other, Properties):<EOL><INDENT>other = other.defined<EOL><DEDENT>for n, v in other.items():<EOL><INDENT>self.set(n, v)<EOL><DEDENT>return self<EOL>
|
Update the property values as specified by keyword/value.
@param other: An object to update from.
@type other: (dict|L{Properties})
@return: self
@rtype: L{Properties}
|
f9693:c4:m2
|
def notset(self, name):
|
self.provider(name).__notset(name)<EOL>
|
Get whether a property has never been set by I{name}.
@param name: A property name.
@type name: str
@return: True if never been set.
@rtype: bool
|
f9693:c4:m3
|
def set(self, name, value):
|
self.provider(name).__set(name, value)<EOL>return self<EOL>
|
Set the I{value} of a property by I{name}.
The value is validated against the definition and set
to the default when I{value} is None.
@param name: The property name.
@type name: str
@param value: The new property value.
@type value: any
@return: self
@rtype: L{Properties}
|
f9693:c4:m4
|
def unset(self, name):
|
self.provider(name).__set(name, None)<EOL>return self<EOL>
|
Unset a property by I{name}.
@param name: A property name.
@type name: str
@return: self
@rtype: L{Properties}
|
f9693:c4:m5
|
def get(self, name, *df):
|
return self.provider(name).__get(name, *df)<EOL>
|
Get the value of a property by I{name}.
@param name: The property name.
@type name: str
@param df: An optional value to be returned when the value
is not set
@type df: [1].
@return: The stored value, or I{df[0]} if not set.
@rtype: any
|
f9693:c4:m6
|
def link(self, other):
|
Link(self, other)<EOL>return self<EOL>
|
Link (associate) this object with anI{other} properties object
to create a network of properties. Links are bidirectional.
@param other: The object to link.
@type other: L{Properties}
@return: self
@rtype: L{Properties}
|
f9693:c4:m7
|
def unlink(self, *others):
|
if not len(others):<EOL><INDENT>others = self.links[:]<EOL><DEDENT>for p in self.links[:]:<EOL><INDENT>if p in others:<EOL><INDENT>p.teardown()<EOL><DEDENT><DEDENT>return self<EOL>
|
Unlink (disassociate) the specified properties object.
@param others: The list object to unlink. Unspecified means unlink all.
@type others: [L{Properties},..]
@return: self
@rtype: L{Properties}
|
f9693:c4:m8
|
def provider(self, name, history=None):
|
if history is None:<EOL><INDENT>history = []<EOL><DEDENT>history.append(self)<EOL>if name in self.definitions:<EOL><INDENT>return self<EOL><DEDENT>for x in self.links:<EOL><INDENT>if x in history:<EOL><INDENT>continue<EOL><DEDENT>provider = x.provider(name, history)<EOL>if provider is not None:<EOL><INDENT>return provider<EOL><DEDENT><DEDENT>history.remove(self)<EOL>if len(history):<EOL><INDENT>return None<EOL><DEDENT>return self<EOL>
|
Find the provider of the property by I{name}.
@param name: The property name.
@type name: str
@param history: A history of nodes checked to prevent
circular hunting.
@type history: [L{Properties},..]
@return: The provider when found. Otherwise, None (when nested)
and I{self} when not nested.
@rtype: L{Properties}
|
f9693:c4:m9
|
def keys(self, history=None):
|
if history is None:<EOL><INDENT>history = []<EOL><DEDENT>history.append(self)<EOL>keys = set()<EOL>keys.update(self.definitions.keys())<EOL>for x in self.links:<EOL><INDENT>if x in history:<EOL><INDENT>continue<EOL><DEDENT>keys.update(x.keys(history))<EOL><DEDENT>history.remove(self)<EOL>return keys<EOL>
|
Get the set of I{all} property names.
@param history: A history of nodes checked to prevent
circular hunting.
@type history: [L{Properties},..]
@return: A set of property names.
@rtype: list
|
f9693:c4:m10
|
def domains(self, history=None):
|
if history is None:<EOL><INDENT>history = []<EOL><DEDENT>history.append(self)<EOL>domains = set()<EOL>domains.add(self.domain)<EOL>for x in self.links:<EOL><INDENT>if x in history:<EOL><INDENT>continue<EOL><DEDENT>domains.update(x.domains(history))<EOL><DEDENT>history.remove(self)<EOL>return domains<EOL>
|
Get the set of I{all} domain names.
@param history: A history of nodes checked to prevent
circular hunting.
@type history: [L{Properties},..]
@return: A set of domain names.
@rtype: list
|
f9693:c4:m11
|
def prime(self):
|
for d in self.definitions.values():<EOL><INDENT>self.defined[d.name] = d.default<EOL><DEDENT>return self<EOL>
|
Prime the stored values based on default values
found in property definitions.
@return: self
@rtype: L{Properties}
|
f9693:c4:m12
|
def get(self, name, *df):
|
return self.properties.get(name, *df)<EOL>
|
Get the value of a property by I{name}.
@param name: The property name.
@type name: str
@param df: An optional value to be returned when the value
is not set
@type df: [1].
@return: The stored value, or I{df[0]} if not set.
@rtype: any
|
f9693:c7:m1
|
def update(self, **kwargs):
|
return self.properties.update(**kwargs)<EOL>
|
Update the property values as specified by keyword/value.
@param kwargs: A list of property name/values to set.
@type kwargs: dict
@return: self
@rtype: L{Properties}
|
f9693:c7:m2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.