MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / Attribute

Class Attribute

suds/sax/attribute.py:29–187  ·  view source on GitHub ↗

An XML attribute object. @ivar parent: The node containing this attribute @type parent: L{element.Element} @ivar prefix: The I{optional} namespace prefix. @type prefix: basestring @ivar name: The I{unqualified} name of the attribute @type name: basestring @ivar value

Source from the content-addressed store, hash-verified

27
28
29class Attribute:
30 """
31 An XML attribute object.
32 @ivar parent: The node containing this attribute
33 @type parent: L{element.Element}
34 @ivar prefix: The I{optional} namespace prefix.
35 @type prefix: basestring
36 @ivar name: The I{unqualified} name of the attribute
37 @type name: basestring
38 @ivar value: The attribute's value
39 @type value: basestring
40 """
41 def __init__(self, name, value=None):
42 """
43 @param name: The attribute's name with I{optional} namespace prefix.
44 @type name: basestring
45 @param value: The attribute's value
46 @type value: basestring
47 """
48 self.parent = None
49 self.prefix, self.name = splitPrefix(name)
50 self.setValue(value)
51
52 def clone(self, parent=None):
53 """
54 Clone this object.
55 @param parent: The parent for the clone.
56 @type parent: L{element.Element}
57 @return: A copy of this object assigned to the new parent.
58 @rtype: L{Attribute}
59 """
60 a = Attribute(self.qname(), self.value)
61 a.parent = parent
62 return a
63
64 def qname(self):
65 """
66 Get the B{fully} qualified name of this attribute
67 @return: The fully qualified name.
68 @rtype: basestring
69 """
70 if self.prefix is None:
71 return self.name
72 else:
73 return ':'.join((self.prefix, self.name))
74
75 def setValue(self, value):
76 """
77 Set the attributes value
78 @param value: The new value (may be None)
79 @type value: basestring
80 @return: self
81 @rtype: L{Attribute}
82 """
83 if isinstance(value, Text):
84 self.value = value
85 else:
86 self.value = Text(value)

Callers 3

setMethod · 0.90
startElementMethod · 0.90
cloneMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected