desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'_do_comment(self, node) -> None
Process a comment node. Render a leading or trailing #xA if the
document order of the comment is greater or lesser (respectively)
than the document element.'
| def _do_comment(self, node):
| if (not _in_subset(self.subset, node)):
return
if self.comments:
W = self.write
if (self.documentOrder == _GreaterElement):
W('\n')
W('<!--')
W(node.data)
W('-->')
if (self.documentOrder == _LesserElement):
W('\n')
|
'\'_do_attr(self, node) -> None
Process an attribute.'
| def _do_attr(self, n, value):
| W = self.write
W(' ')
W(n)
W('="')
s = string.replace(value, '&', '&')
s = string.replace(s, '<', '<')
s = string.replace(s, '"', '"')
s = string.replace(s, ' DCTB ', '	')
s = string.replace(s, '\n', '
')
s = string.replace(s, '\r', '
')
W(s)
W('"'... |
'_do_element(self, node, initial_other_attrs = [], unused = {}) -> None
Process an element (and its children).'
| def _do_element(self, node, initial_other_attrs=[], unused=None):
| (ns_parent, ns_rendered, xml_attrs) = (self.state[0], self.state[1].copy(), self.state[2].copy())
ns_unused_inherited = unused
if (unused is None):
ns_unused_inherited = self.state[3].copy()
ns_local = ns_parent.copy()
inclusive = _inclusive(self)
xml_attrs_local = {}
other_attrs = [... |
'Return a WSDL instance loaded from a stream object.'
| def loadFromStream(self, stream, name=None):
| document = DOM.loadDocument(stream)
wsdl = WSDL()
if name:
wsdl.location = name
elif hasattr(stream, 'name'):
wsdl.location = stream.name
wsdl.load(document)
return wsdl
|
'Return a WSDL instance loaded from the given url.'
| def loadFromURL(self, url):
| document = DOM.loadFromURL(url)
wsdl = WSDL()
wsdl.location = url
wsdl.load(document)
return wsdl
|
'Return a WSDL instance loaded from an xml string.'
| def loadFromString(self, data):
| return self.loadFromStream(StringIO(data))
|
'Return a WSDL instance loaded from the given file.'
| def loadFromFile(self, filename):
| file = open(filename, 'rb')
try:
wsdl = self.loadFromStream(file)
finally:
file.close()
return wsdl
|
'Generate a DOM representation of the WSDL instance.
Not dealing with generating XML Schema, thus the targetNamespace
of all XML Schema elements or types used by WSDL message parts
needs to be specified via import information items.'
| def toDom(self):
| namespaceURI = DOM.GetWSDLUri(self.version)
self.document = DOM.createDocument(namespaceURI, 'wsdl:definitions')
child = DOM.getElement(self.document, None)
child.setAttributeNS(None, 'targetNamespace', self.targetNamespace)
child.setAttributeNS(XMLNS.BASE, 'xmlns:wsdl', namespaceURI)
child.setA... |
'Algo take <import> element\'s children, clone them,
and add them to the main document. Support for relative
locations is a bit complicated. The orig document context
is lost, so we need to store base location in DOM elements
representing <types>, by creating a special temporary
"base-location" attribute, and <impor... | def _import(self, document, element, base_location=None):
| namespace = DOM.getAttr(element, 'namespace', default=None)
location = DOM.getAttr(element, 'location', default=None)
if ((namespace is None) or (location is None)):
raise WSDLError('Invalid import element (missing namespace or location).')
if base_location:
location = ... |
'Return the WSDL object that contains this information item.'
| def getWSDL(self):
| parent = self
while 1:
if isinstance(parent, WSDL):
return parent
try:
parent = parent.parent()
except:
break
return None
|
'node -- node representing message'
| def toDom(self, node):
| wsdl = self.getWSDL()
ep = ElementProxy(None, node)
epc = ep.createAppendElement(DOM.GetWSDLUri(wsdl.version), 'part')
epc.setAttributeNS(None, 'name', self.name)
if (self.element is not None):
(ns, name) = self.element
prefix = epc.getPrefix(ns)
epc.setAttributeNS(None, 'ele... |
'Return the WSDL object that contains this Operation.'
| def getWSDL(self):
| return self.parent().parent().parent().parent()
|
'wsa:Action attribute'
| def getInputAction(self):
| return GetWSAActionInput(self)
|
'wsa:Action attribute'
| def getOutputAction(self):
| return GetWSAActionOutput(self)
|
'wsa:Action attribute'
| def getFaultAction(self, name):
| return GetWSAActionFault(self, name)
|
'Return the WSDL object that contains this information item.'
| def getWSDL(self):
| parent = self
while 1:
if isinstance(parent, WSDL):
return parent
try:
parent = parent.parent()
except:
break
return None
|
'Return the WSDL object that represents the attribute message
(namespaceURI, name) tuple'
| def getMessage(self):
| wsdl = self.getWSDL()
return wsdl.messages[self.message]
|
'Return the PortType object associated with this binding.'
| def getPortType(self):
| return self.getWSDL().portTypes[self.type]
|
'Return the parent Binding object of the operation binding.'
| def getBinding(self):
| return self.parent().parent()
|
'Return the abstract Operation associated with this binding.'
| def getOperation(self):
| return self.getBinding().getPortType().operations[self.name]
|
'Return the Service object associated with this port.'
| def getService(self):
| return self.parent().parent()
|
'Return the Binding object that is referenced by this port.'
| def getBinding(self):
| wsdl = self.getService().getWSDL()
return wsdl.bindings[self.binding]
|
'Return the PortType object that is referenced by this port.'
| def getPortType(self):
| wsdl = self.getService().getWSDL()
binding = wsdl.bindings[self.binding]
return wsdl.portTypes[binding.type]
|
'A convenience method to obtain the extension element used
as the address binding for the port.'
| def getAddressBinding(self):
| for item in self.extensions:
if (isinstance(item, SoapAddressBinding) or isinstance(item, HttpAddressBinding)):
return item
raise WSDLError('No address binding found in port.')
|
'Add an input parameter description to the call info.'
| def addInParameter(self, name, type, namespace=None, element_type=0):
| parameter = ParameterInfo(name, type, namespace, element_type)
self.inparams.append(parameter)
return parameter
|
'Add an output parameter description to the call info.'
| def addOutParameter(self, name, type, namespace=None, element_type=0):
| parameter = ParameterInfo(name, type, namespace, element_type)
self.outparams.append(parameter)
return parameter
|
'Set the return parameter description for the call info.'
| def setReturnParameter(self, name, type, namespace=None, element_type=0):
| parameter = ParameterInfo(name, type, namespace, element_type)
self.retval = parameter
return parameter
|
'Add an input SOAP header description to the call info.'
| def addInHeaderInfo(self, name, type, namespace, element_type=0, mustUnderstand=0):
| headerinfo = HeaderInfo(name, type, namespace, element_type)
if mustUnderstand:
headerinfo.mustUnderstand = 1
self.inheaders.append(headerinfo)
return headerinfo
|
'Add an output SOAP header description to the call info.'
| def addOutHeaderInfo(self, name, type, namespace, element_type=0, mustUnderstand=0):
| headerinfo = HeaderInfo(name, type, namespace, element_type)
if mustUnderstand:
headerinfo.mustUnderstand = 1
self.outheaders.append(headerinfo)
return headerinfo
|
'Return a sequence of the in parameters of the method.'
| def getInParameters(self):
| return self.inparams
|
'Return a sequence of the out parameters of the method.'
| def getOutParameters(self):
| return self.outparams
|
'Return param info about the return value of the method.'
| def getReturnParameter(self):
| return self.retval
|
'Return a sequence of the in headers of the method.'
| def getInHeaders(self):
| return self.inheaders
|
'Return a sequence of the out headers of the method.'
| def getOutHeaders(self):
| return self.outheaders
|
'it return a string with the MIME message'
| def toString(self):
| if (len(self._boundary) == 0):
self.makeBoundary()
returnstr = (((NL + '--') + self._boundary) + NL)
returnstr += ('Content-Type: text/xml; charset="us-ascii"' + NL)
returnstr += ('Content-Transfer-Encoding: 7bit' + NL)
returnstr += ((('Content-Id: ' + self._startCID) + NL) + NL)... |
'it adds a file to this attachment'
| def attachFile(self, file):
| self._files.append(file)
|
'it adds the XML message. we can have only one XML SOAP message'
| def addXMLMessage(self, xmlMessage):
| self._xmlMessage = xmlMessage
|
'this function returns the string used in the mime message as a
boundary. First the write method as to be called'
| def getBoundary(self):
| return self._boundary
|
'This function returns the CID of the XML message'
| def getStartCID(self):
| return self._startCID
|
'Return the SOAP version related to an envelope uri.'
| def SOAPUriToVersion(self, uri):
| value = self._soap_uri_mapping.get(uri)
if (value is not None):
return value
raise ValueError(('Unsupported SOAP envelope uri: %s' % uri))
|
'Return the appropriate SOAP envelope uri for a given
human-friendly SOAP version string (e.g. \'1.1\').'
| def GetSOAPEnvUri(self, version):
| attrname = ('NS_SOAP_ENV_%s' % join(split(version, '.'), '_'))
value = getattr(self, attrname, None)
if (value is not None):
return value
raise ValueError(('Unsupported SOAP version: %s' % version))
|
'Return the appropriate SOAP encoding uri for a given
human-friendly SOAP version string (e.g. \'1.1\').'
| def GetSOAPEncUri(self, version):
| attrname = ('NS_SOAP_ENC_%s' % join(split(version, '.'), '_'))
value = getattr(self, attrname, None)
if (value is not None):
return value
raise ValueError(('Unsupported SOAP version: %s' % version))
|
'Return the right special next-actor uri for a given
human-friendly SOAP version string (e.g. \'1.1\').'
| def GetSOAPActorNextUri(self, version):
| attrname = ('SOAP_ACTOR_NEXT_%s' % join(split(version, '.'), '_'))
value = getattr(self, attrname, None)
if (value is not None):
return value
raise ValueError(('Unsupported SOAP version: %s' % version))
|
'Return the appropriate matching XML Schema instance uri for
the given XML Schema namespace uri.'
| def InstanceUriForSchemaUri(self, uri):
| return self._xsd_uri_mapping.get(uri)
|
'Return the appropriate matching XML Schema namespace uri for
the given XML Schema instance namespace uri.'
| def SchemaUriForInstanceUri(self, uri):
| return self._xsd_uri_mapping.get(uri)
|
'Return the WSDL version related to a WSDL namespace uri.'
| def WSDLUriToVersion(self, uri):
| value = self._wsdl_uri_mapping.get(uri)
if (value is not None):
return value
raise ValueError(('Unsupported SOAP envelope uri: %s' % uri))
|
'Return true if the given node is an element with the given
name and optional namespace uri.'
| def isElement(self, node, name, nsuri=None):
| if (node.nodeType != node.ELEMENT_NODE):
return 0
return ((node.localName == name) and ((nsuri is None) or self.nsUriMatch(node.namespaceURI, nsuri)))
|
'Return the first child of node with a matching name and
namespace uri, or the default if one is provided.'
| def getElement(self, node, name, nsuri=None, default=join):
| nsmatch = self.nsUriMatch
ELEMENT_NODE = node.ELEMENT_NODE
for child in node.childNodes:
if (child.nodeType == ELEMENT_NODE):
if (((child.localName == name) or (name is None)) and ((nsuri is None) or nsmatch(child.namespaceURI, nsuri))):
return child
if (default is no... |
'Return the first child of node matching an id reference.'
| def getElementById(self, node, id, default=join):
| attrget = self.getAttr
ELEMENT_NODE = node.ELEMENT_NODE
for child in node.childNodes:
if (child.nodeType == ELEMENT_NODE):
if (attrget(child, 'id') == id):
return child
if (default is not join):
return default
raise KeyError, name
|
'Create an id -> element mapping of those elements within a
document that define an id attribute. The depth of the search
may be controlled by using the (1-based) depth argument.'
| def getMappingById(self, document, depth=None, element=None, mapping=None, level=1):
| if (document is not None):
element = document.documentElement
mapping = {}
attr = element._attrs.get('id', None)
if (attr is not None):
mapping[attr.value] = element
if ((depth is None) or (depth > level)):
level = (level + 1)
ELEMENT_NODE = element.ELEMENT_NODE
... |
'Return a sequence of the child elements of the given node that
match the given name and optional namespace uri.'
| def getElements(self, node, name, nsuri=None):
| nsmatch = self.nsUriMatch
result = []
ELEMENT_NODE = node.ELEMENT_NODE
for child in node.childNodes:
if (child.nodeType == ELEMENT_NODE):
if (((child.localName == name) or (name is None)) and ((nsuri is None) or nsmatch(child.namespaceURI, nsuri))):
result.append(chil... |
'Return true if element has attribute with the given name and
optional nsuri. If nsuri is not specified, returns true if an
attribute exists with the given name with any namespace.'
| def hasAttr(self, node, name, nsuri=None):
| if (nsuri is None):
if node.hasAttribute(name):
return True
return False
return node.hasAttributeNS(nsuri, name)
|
'Return the value of the attribute named \'name\' with the
optional nsuri, or the default if one is specified. If
nsuri is not specified, an attribute that matches the
given name will be returned regardless of namespace.'
| def getAttr(self, node, name, nsuri=None, default=join):
| if (nsuri is None):
result = node._attrs.get(name, None)
if (result is None):
for item in node._attrsNS.keys():
if (item[1] == name):
result = node._attrsNS[item]
break
else:
result = node._attrsNS.get((nsuri, name), Non... |
'Return a Collection of all attributes'
| def getAttrs(self, node):
| attrs = {}
for (k, v) in node._attrs.items():
attrs[k] = v.value
return attrs
|
'Return the text value of an xml element node. Leading and trailing
whitespace is stripped from the value unless the preserve_ws flag
is passed with a true value.'
| def getElementText(self, node, preserve_ws=None):
| result = []
for child in node.childNodes:
nodetype = child.nodeType
if ((nodetype == child.TEXT_NODE) or (nodetype == child.CDATA_SECTION_NODE)):
result.append(child.nodeValue)
value = join(result, '')
if (preserve_ws is None):
value = strip(value)
return value
|
'Find a namespace uri given a prefix and a context node.'
| def findNamespaceURI(self, prefix, node):
| attrkey = (self.NS_XMLNS, prefix)
DOCUMENT_NODE = node.DOCUMENT_NODE
ELEMENT_NODE = node.ELEMENT_NODE
while 1:
if (node is None):
raise DOMException(('Value for prefix %s not found.' % prefix))
if (node.nodeType != ELEMENT_NODE):
node = node.parentN... |
'Return the current default namespace uri for the given node.'
| def findDefaultNS(self, node):
| attrkey = (self.NS_XMLNS, 'xmlns')
DOCUMENT_NODE = node.DOCUMENT_NODE
ELEMENT_NODE = node.ELEMENT_NODE
while 1:
if (node.nodeType != ELEMENT_NODE):
node = node.parentNode
continue
result = node._attrsNS.get(attrkey, None)
if (result is not None):
... |
'Return the defined target namespace uri for the given node.'
| def findTargetNS(self, node):
| attrget = self.getAttr
attrkey = (self.NS_XMLNS, 'xmlns')
DOCUMENT_NODE = node.DOCUMENT_NODE
ELEMENT_NODE = node.ELEMENT_NODE
while 1:
if (node.nodeType != ELEMENT_NODE):
node = node.parentNode
continue
result = attrget(node, 'targetNamespace', default=None)
... |
'Return (namespaceURI, name) for a type attribue of the given
element, or None if the element does not have a type attribute.'
| def getTypeRef(self, element):
| typeattr = self.getAttr(element, 'type', default=None)
if (typeattr is None):
return None
parts = typeattr.split(':', 1)
if (len(parts) == 2):
nsuri = self.findNamespaceURI(parts[0], element)
else:
nsuri = self.findDefaultNS(element)
return (nsuri, parts[1])
|
'Implements (well enough for our purposes) DOM node import.'
| def importNode(self, document, node, deep=0):
| nodetype = node.nodeType
if (nodetype in (node.DOCUMENT_NODE, node.DOCUMENT_TYPE_NODE)):
raise DOMException('Illegal node type for importNode')
if (nodetype == node.ENTITY_REFERENCE_NODE):
deep = 0
clone = node.cloneNode(deep)
self._setOwnerDoc(document, clone)
clone.... |
'Return a true value if two namespace uri values match.'
| def nsUriMatch(self, value, wanted, strict=0, tt=type(())):
| if ((value == wanted) or ((type(wanted) is tt) and (value in wanted))):
return 1
if ((not strict) and (value is not None)):
wanted = (((type(wanted) is tt) and wanted) or (wanted,))
value = (((value[(-1):] != '/') and value) or value[:(-1)])
for item in wanted:
if ((i... |
'Create a new writable DOM document object.'
| def createDocument(self, nsuri, qname, doctype=None):
| impl = xml.dom.minidom.getDOMImplementation()
return impl.createDocument(nsuri, qname, doctype)
|
'Load an xml file from a file-like object and return a DOM
document instance.'
| def loadDocument(self, data):
| return xml.dom.minidom.parse(data)
|
'Load an xml file from a URL and return a DOM document.'
| def loadFromURL(self, url):
| if (isfile(url) is True):
file = open(url, 'r')
else:
file = urlopen(url)
try:
result = self.loadDocument(file)
except Exception as ex:
file.close()
raise ParseError(((('Failed to load document %s' % url),) + ex.args))
else:
file.close()
... |
'Constructor, May be extended, do not override.
sw -- soapWriter instance'
| def __init__(self, sw):
| self.sw = None
if ((type(sw) != weakref.ReferenceType) and (sw is not None)):
self.sw = weakref.ref(sw)
else:
self.sw = sw
|
'canonicalize the underlying DOM, and return as string.'
| def canonicalize(self):
| raise NotImplementedError, ''
|
'create Document'
| def createDocument(self, namespaceURI=SOAP.ENV, localName='Envelope'):
| raise NotImplementedError, ''
|
'create and append element(namespaceURI,localName), and return
the node.'
| def createAppendElement(self, namespaceURI, localName):
| raise NotImplementedError, ''
|
'set attribute (namespaceURI, localName)=value'
| def setAttributeNS(self, namespaceURI, localName, value):
| raise NotImplementedError, ''
|
'set attribute xsi:type=(namespaceURI, localName)'
| def setAttributeType(self, namespaceURI, localName):
| raise NotImplementedError, ''
|
'set namespace attribute xmlns:prefix=namespaceURI'
| def setNamespaceAttribute(self, namespaceURI, prefix):
| raise NotImplementedError, ''
|
'Initialize.
sw -- SoapWriter'
| def __init__(self, sw, message=None):
| self._indx = 0
MessageInterface.__init__(self, sw)
Base.__init__(self)
self._dom = DOM
self.node = None
if (type(message) in (types.StringType, types.UnicodeType)):
self.loadFromString(message)
elif isinstance(message, ElementProxy):
self.node = message._getNode()
else:
... |
'expression -- XPath compiled expression'
| def evaluate(self, expression, processorNss=None):
| from Ft.Xml import XPath
if (not processorNss):
context = XPath.Context.Context(self.node, processorNss=self.processorNss)
else:
context = XPath.Context.Context(self.node, processorNss=processorNss)
nodes = expression.evaluate(context)
return map((lambda node: ElementProxy(self.sw, n... |
'namespaceURI -- namespace of element
localName -- local name of element'
| def checkNode(self, namespaceURI=None, localName=None):
| namespaceURI = (namespaceURI or self.namespaceURI)
localName = (localName or self.name)
check = False
if (localName and self.node):
check = self._dom.isElement(self.node, localName, namespaceURI)
if (not check):
raise NamespaceError, ('unexpected node type %s, expecting ... |
'I guess we need to resolve all potential prefixes
because when the current node is attached it copies the
namespaces into the parent node.'
| def _getUniquePrefix(self):
| while 1:
self._indx += 1
prefix = ('ns%d' % self._indx)
try:
self._dom.findNamespaceURI(prefix, self._getNode())
except DOMException as ex:
break
return prefix
|
'Keyword arguments:
node -- DOM Element Node
nsuri -- namespace of attribute value'
| def _getPrefix(self, node, nsuri):
| try:
if (node and (node.nodeType == node.ELEMENT_NODE) and (nsuri == self._dom.findDefaultNS(node))):
return None
except DOMException as ex:
pass
if (nsuri == XMLNS.XML):
return self._xml_prefix
if (node.nodeType == Node.ELEMENT_NODE):
for attr in node.attribu... |
'Keyword arguments:
node -- DOM Element Node'
| def _appendChild(self, node):
| if (node is None):
raise TypeError, 'node is None'
self.node.appendChild(node)
|
'Keyword arguments:
child -- DOM Element Node to insert
refChild -- DOM Element Node'
| def _insertBefore(self, newChild, refChild):
| self.node.insertBefore(newChild, refChild)
|
'Keyword arguments:
namespaceURI -- namespace of attribute
qualifiedName -- qualified name of new attribute value
value -- value of attribute'
| def _setAttributeNS(self, namespaceURI, qualifiedName, value):
| self.node.setAttributeNS(namespaceURI, qualifiedName, value)
|
'check to see if this is a soap:fault message.'
| def isFault(self):
| return False
|
'If specified must be a SOAP envelope, else may contruct an empty document.'
| def createDocument(self, namespaceURI, localName, doctype=None):
| prefix = self._soap_env_prefix
if (namespaceURI == self.reserved_ns[prefix]):
qualifiedName = ('%s:%s' % (prefix, localName))
elif (namespaceURI is localName is None):
self.node = self._dom.createDocument(None, None, None)
return
else:
raise KeyError, ('only support ... |
'set xsi:type
Keyword arguments:
namespaceURI -- namespace of attribute value
localName -- name of new attribute value'
| def setAttributeType(self, namespaceURI, localName):
| self.logger.debug('setAttributeType: (%s,%s)', namespaceURI, localName)
value = localName
if namespaceURI:
value = ('%s:%s' % (self.getPrefix(namespaceURI), localName))
xsi_prefix = self.getPrefix(self._xsi_nsuri)
self._setAttributeNS(self._xsi_nsuri, ('%s:type' % xsi_prefix), value)
|
'Keyword arguments:
namespaceURI -- namespace of attribute to create, None is for
attributes in no namespace.
localName -- local name of new attribute
value -- value of new attribute'
| def setAttributeNS(self, namespaceURI, localName, value):
| prefix = None
if namespaceURI:
try:
prefix = self.getPrefix(namespaceURI)
except KeyError as ex:
prefix = 'ns2'
self.setNamespaceAttribute(prefix, namespaceURI)
qualifiedName = localName
if prefix:
qualifiedName = ('%s:%s' % (prefix, localName)... |
'Keyword arguments:
prefix -- xmlns prefix
namespaceURI -- value of prefix'
| def setNamespaceAttribute(self, prefix, namespaceURI):
| self._setAttributeNS(XMLNS.BASE, ('xmlns:%s' % prefix), namespaceURI)
|
'Keyword arguments:
namespace -- namespace of element to create
qname -- qualified name of new element'
| def createElementNS(self, namespace, qname):
| document = self._getOwnerDocument()
node = document.createElementNS(namespace, qname)
return ElementProxy(self.sw, node)
|
'Create a new element (namespaceURI,name), append it
to current node, then set it to be the current node.
Keyword arguments:
namespaceURI -- namespace of element to create
localName -- local name of new element
prefix -- if namespaceURI is not defined, declare prefix. defaults
to \'ns1\' if left unspecified.'
| def createAppendSetElement(self, namespaceURI, localName, prefix=None):
| node = self.createAppendElement(namespaceURI, localName, prefix=None)
node = node._getNode()
self._setNode(node._getNode())
|
'Create a new element (namespaceURI,name), append it
to current node, and return the newly created node.
Keyword arguments:
namespaceURI -- namespace of element to create
localName -- local name of new element
prefix -- if namespaceURI is not defined, declare prefix. defaults
to \'ns1\' if left unspecified.'
| def createAppendElement(self, namespaceURI, localName, prefix=None):
| declare = False
qualifiedName = localName
if namespaceURI:
try:
prefix = self.getPrefix(namespaceURI)
except:
declare = True
prefix = (prefix or self._getUniquePrefix())
if prefix:
qualifiedName = ('%s:%s' % (prefix, localName))
nod... |
'Keyword arguments:
namespaceURI -- namespace of element
localName -- local name of element'
| def getElement(self, namespaceURI, localName):
| node = self._dom.getElement(self.node, localName, namespaceURI, default=None)
if node:
return ElementProxy(self.sw, node)
return None
|
'Keyword arguments:
namespaceURI -- namespace of attribute
localName -- local name of attribute'
| def getAttributeValue(self, namespaceURI, localName):
| if self.hasAttribute(namespaceURI, localName):
attr = self.node.getAttributeNodeNS(namespaceURI, localName)
return attr.value
return None
|
'Set up environment then let parent class handle call.
Raises AttributeError is method name is not found.'
| def __getattr__(self, name):
| if (not self.methods.has_key(name)):
raise AttributeError, name
callinfo = self.methods[name]
self.soapproxy.proxy = SOAPAddress(callinfo.location)
self.soapproxy.namespace = callinfo.namespace
self.soapproxy.soapaction = callinfo.soapAction
return self.soapproxy.__getattr__(name)
|
'Provide a default host, since the superclass requires one.'
| def __init__(self, host='', port=None, strict=None, timeout=None):
| if (port == 0):
port = None
self._setup(self._connection_class(host, port, strict, timeout))
|
'Extract the (possibly extended) namespace from the returned
SOAP message.'
| def getNS(self, original_namespace, data):
| if (type(original_namespace) == StringType):
pattern = (('xmlns:\\w+=[\'"](' + original_namespace) + '[^\'"]*)[\'"]')
match = re.search(pattern, data)
if match:
return match.group(1)
else:
return original_namespace
else:
return original_namespace
|
'Add cookies from self.cookies to request r'
| def __addcookies(self, r):
| for (cname, morsel) in self.cookies.items():
attrs = []
value = morsel.get('version', '')
if ((value != '') and (value != '0')):
attrs.append(('$Version=%s' % value))
attrs.append(('%s=%s' % (cname, morsel.coded_value)))
value = morsel.get('path')
if value... |
'Datagram received, we callback the IP address.'
| def datagramReceived(self, dgram, addr):
| logging.debug('Received multicast pong: %s; addr:%r', dgram, addr)
if (dgram != self.nonce):
return
self.address_received.happened(addr[0])
|
'Create a mapping for the given twisted\'s port object.
The deferred will call back with a tuple (extaddr, extport):
- extaddr: The ip string of the external ip address of this host
- extport: the external port number used to map the given Port object
When called multiple times with the same Port,
callback with the exi... | def map(self, port):
| raise NotImplementedError
|
'Returns the existing mapping for the given port object. That means map()
has to be called before.
@param port: The port object to retreive info from
@type port: a L{twisted.internet.interfaces.IListeningPort} object
@raise ValueError: When there is no such existing mapping
@return: a tuple (extaddress, extport).
@see:... | def info(self, port):
| raise NotImplementedError
|
'Remove an existing mapping for the given twisted\'s port object.
@param port: The port object to unmap
@type port: a L{twisted.internet.interfaces.IListeningPort} object
@return: A deferred called with None
@rtype: L{twisted.internet.defer.Deferred}
@raise ValueError: When there is no such existing mapping'
| def unmap(self, port):
| raise NotImplementedError
|
'Returns a deferred that will be called with a dictionnary of the
existing mappings.
The dictionnary structure is the following:
- Keys: tuple (protocol, external_port)
- protocol is "TCP" or "UDP".
- external_port is the external port number, as see on the
WAN side.
- Values:tuple (internal_ip, internal_port)
- intern... | def get_port_mappings(self):
| raise NotImplementedError
|
'Various Port object validity checks. Raise a ValueError.'
| def _check_valid_port(self, port):
| if (not isinstance(port, BasePort)):
raise ValueError(('expected a Port, got %r' % port))
if (not port.connected):
raise ValueError(('Port %r is not listening' % port))
loc_addr = port.getHost()
if (loc_addr.port == 0):
raise ValueError(('Port %r has... |
'Parse the given XML string for UPnP infos. This creates the attributes
when they are found, or None if no value was found.
@param xml: a xml string to parse'
| def __init__(self, xml):
| logging.debug('Got UPNP Xml description:\n%s', xml)
doc = minidom.parseString(xml)
self.deviceinfos = {}
try:
attributes = {'friendlyname': 'friendlyName', 'manufacturer': 'manufacturer'}
device = doc.getElementsByTagName('device')[0]
for (name, tag) in attributes.iterit... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.