mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-30 19:19:55 +00:00
Modified ElementBase _getSubText, _setSubText, and _delSubText to
use the namespace in a tag name if one is given and to use self.namespace otherwise.
This commit is contained in:
parent
e8e934fa95
commit
d148f633f3
1 changed files with 10 additions and 5 deletions
|
@ -239,26 +239,31 @@ class ElementBase(tostring.ToString):
|
||||||
return self.xml.attrib.get(name, '')
|
return self.xml.attrib.get(name, '')
|
||||||
|
|
||||||
def _getSubText(self, name):
|
def _getSubText(self, name):
|
||||||
stanza = self.xml.find("{%s}%s" % (self.namespace, name))
|
if '}' not in name:
|
||||||
|
name = "{%s}%s" % (self.namespace, name)
|
||||||
|
stanza = self.xml.find(name)
|
||||||
if stanza is None or stanza.text is None:
|
if stanza is None or stanza.text is None:
|
||||||
return ''
|
return ''
|
||||||
else:
|
else:
|
||||||
return stanza.text
|
return stanza.text
|
||||||
|
|
||||||
def _setSubText(self, name, attrib={}, text=None):
|
def _setSubText(self, name, attrib={}, text=None):
|
||||||
|
if '}' not in name:
|
||||||
|
name = "{%s}%s" % (self.namespace, name)
|
||||||
if text is None or text == '':
|
if text is None or text == '':
|
||||||
return self.__delitem__(name)
|
return self.__delitem__(name)
|
||||||
stanza = self.xml.find("{%s}%s" % (self.namespace, name))
|
stanza = self.xml.find(name)
|
||||||
if stanza is None:
|
if stanza is None:
|
||||||
#self.xml.append(ET.Element("{%s}%s" % (self.namespace, name), attrib))
|
stanza = ET.Element(name)
|
||||||
stanza = ET.Element("{%s}%s" % (self.namespace, name))
|
|
||||||
self.xml.append(stanza)
|
self.xml.append(stanza)
|
||||||
stanza.text = text
|
stanza.text = text
|
||||||
return stanza
|
return stanza
|
||||||
|
|
||||||
def _delSub(self, name):
|
def _delSub(self, name):
|
||||||
|
if '}' not in name:
|
||||||
|
name = "{%s}%s" % (self.namespace, name)
|
||||||
for child in self.xml.getchildren():
|
for child in self.xml.getchildren():
|
||||||
if child.tag == "{%s}%s" % (self.namespace, name):
|
if child.tag == name:
|
||||||
self.xml.remove(child)
|
self.xml.remove(child)
|
||||||
|
|
||||||
def getStanzaValues(self):
|
def getStanzaValues(self):
|
||||||
|
|
Loading…
Reference in a new issue