summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2010-08-26 14:19:36 -0400
committerLance Stout <lancestout@gmail.com>2010-08-26 14:19:36 -0400
commit56766508b3550f6dbf9ea89516c6423842011494 (patch)
treebccf6b17c8ec74c487bfcc429fd85058200d4824
parent5c59f5bacaec6263d4b860856cd76b5b7bb1a531 (diff)
downloadslixmpp-56766508b3550f6dbf9ea89516c6423842011494.tar.gz
slixmpp-56766508b3550f6dbf9ea89516c6423842011494.tar.bz2
slixmpp-56766508b3550f6dbf9ea89516c6423842011494.tar.xz
slixmpp-56766508b3550f6dbf9ea89516c6423842011494.zip
Fixed indentation in StanzaBase.
-rw-r--r--sleekxmpp/xmlstream/stanzabase.py149
1 files changed, 77 insertions, 72 deletions
diff --git a/sleekxmpp/xmlstream/stanzabase.py b/sleekxmpp/xmlstream/stanzabase.py
index abe288db..854aceba 100644
--- a/sleekxmpp/xmlstream/stanzabase.py
+++ b/sleekxmpp/xmlstream/stanzabase.py
@@ -875,85 +875,90 @@ class ElementBase(object):
class StanzaBase(ElementBase):
- name = 'stanza'
- namespace = 'jabber:client'
- interfaces = set(('type', 'to', 'from', 'id', 'payload'))
- types = set(('get', 'set', 'error', None, 'unavailable', 'normal', 'chat'))
- sub_interfaces = tuple()
-
- def __init__(self, stream=None, xml=None, stype=None, sto=None, sfrom=None, sid=None):
- self.stream = stream
- if stream is not None:
- self.namespace = stream.default_ns
- ElementBase.__init__(self, xml)
- if stype is not None:
- self['type'] = stype
- if sto is not None:
- self['to'] = sto
- if sfrom is not None:
- self['from'] = sfrom
- self.tag = "{%s}%s" % (self.namespace, self.name)
-
- def setType(self, value):
- if value in self.types:
- self.xml.attrib['type'] = value
- return self
-
- def getPayload(self):
- return self.xml.getchildren()
-
- def setPayload(self, value):
- self.xml.append(value)
- return self
-
- def delPayload(self):
- self.clear()
- return self
-
- def clear(self):
- for child in self.xml.getchildren():
- self.xml.remove(child)
- for plugin in list(self.plugins.keys()):
- del self.plugins[plugin]
- return self
-
- def reply(self):
- # if it's a component, use from
- if self.stream and hasattr(self.stream, "is_component") and self.stream.is_component:
- self['from'], self['to'] = self['to'], self['from']
- else:
- self['to'] = self['from']
- del self['from']
- self.clear()
- return self
+ name = 'stanza'
+ namespace = 'jabber:client'
+ interfaces = set(('type', 'to', 'from', 'id', 'payload'))
+ types = set(('get', 'set', 'error', None, 'unavailable', 'normal', 'chat'))
+ sub_interfaces = tuple()
+
+ def __init__(self, stream=None, xml=None, stype=None,
+ sto=None, sfrom=None, sid=None):
+ self.stream = stream
+ if stream is not None:
+ self.namespace = stream.default_ns
+ ElementBase.__init__(self, xml)
+ if stype is not None:
+ self['type'] = stype
+ if sto is not None:
+ self['to'] = sto
+ if sfrom is not None:
+ self['from'] = sfrom
+ self.tag = "{%s}%s" % (self.namespace, self.name)
+
+ def setType(self, value):
+ if value in self.types:
+ self.xml.attrib['type'] = value
+ return self
+
+ def getPayload(self):
+ return self.xml.getchildren()
+
+ def setPayload(self, value):
+ self.xml.append(value)
+ return self
- def error(self):
- self['type'] = 'error'
- return self
+ def delPayload(self):
+ self.clear()
+ return self
- def getTo(self):
- return JID(self._getAttr('to'))
+ def clear(self):
+ for child in self.xml.getchildren():
+ self.xml.remove(child)
+ for plugin in list(self.plugins.keys()):
+ del self.plugins[plugin]
+ return self
- def setTo(self, value):
- return self._setAttr('to', str(value))
+ def reply(self):
+ # if it's a component, use from
+ if self.stream and hasattr(self.stream, "is_component") and \
+ self.stream.is_component:
+ self['from'], self['to'] = self['to'], self['from']
+ else:
+ self['to'] = self['from']
+ del self['from']
+ self.clear()
+ return self
- def getFrom(self):
- return JID(self._getAttr('from'))
+ def error(self):
+ self['type'] = 'error'
+ return self
- def setFrom(self, value):
- return self._setAttr('from', str(value))
+ def getTo(self):
+ return JID(self._getAttr('to'))
- def unhandled(self):
- pass
+ def setTo(self, value):
+ return self._setAttr('to', str(value))
- def exception(self, e):
- logging.exception('Error handling {%s}%s stanza' % (self.namespace, self.name))
+ def getFrom(self):
+ return JID(self._getAttr('from'))
- def send(self):
- self.stream.sendRaw(self.__str__())
+ def setFrom(self, value):
+ return self._setAttr('from', str(value))
- def __copy__(self):
- return self.__class__(xml=copy.deepcopy(self.xml), stream=self.stream)
+ def unhandled(self):
+ pass
- def __str__(self):
- return tostring(self.xml, xmlns='', stanza_ns=self.namespace, stream=self.stream)
+ def exception(self, e):
+ logging.exception('Error handling {%s}%s stanza' % (self.namespace,
+ self.name))
+
+ def send(self):
+ self.stream.sendRaw(self.__str__())
+
+ def __copy__(self):
+ return self.__class__(xml=copy.deepcopy(self.xml), stream=self.stream)
+
+ def __str__(self):
+ return tostring(self.xml, xmlns='',
+ stanza_ns=self.namespace,
+ stream=self.stream)