Remap old method names in a better way.
This should prevent some reference cycles that will cause garbage collection issues.
This commit is contained in:
@@ -77,15 +77,6 @@ class Error(ElementBase):
|
||||
Arguments:
|
||||
xml -- Use an existing XML object for the stanza's values.
|
||||
"""
|
||||
# To comply with PEP8, method names now use underscores.
|
||||
# Deprecated method names are re-mapped for backwards compatibility.
|
||||
self.getCondition = self.get_condition
|
||||
self.setCondition = self.set_condition
|
||||
self.delCondition = self.del_condition
|
||||
self.getText = self.get_text
|
||||
self.setText = self.set_text
|
||||
self.delText = self.del_text
|
||||
|
||||
if ElementBase.setup(self, xml):
|
||||
#If we had to generate XML then set default values.
|
||||
self['type'] = 'cancel'
|
||||
@@ -139,3 +130,13 @@ class Error(ElementBase):
|
||||
"""Remove the <text> element."""
|
||||
self._del_sub('{%s}text' % self.condition_ns)
|
||||
return self
|
||||
|
||||
|
||||
# To comply with PEP8, method names now use underscores.
|
||||
# Deprecated method names are re-mapped for backwards compatibility.
|
||||
Error.getCondition = Error.get_condition
|
||||
Error.setCondition = Error.set_condition
|
||||
Error.delCondition = Error.del_condition
|
||||
Error.getText = Error.get_text
|
||||
Error.setText = Error.set_text
|
||||
Error.delText = Error.del_text
|
||||
|
||||
@@ -46,23 +46,6 @@ class HTMLIM(ElementBase):
|
||||
interfaces = set(('body',))
|
||||
plugin_attrib = name
|
||||
|
||||
def setup(self, xml=None):
|
||||
"""
|
||||
Populate the stanza object using an optional XML object.
|
||||
|
||||
Overrides StanzaBase.setup.
|
||||
|
||||
Arguments:
|
||||
xml -- Use an existing XML object for the stanza's values.
|
||||
"""
|
||||
# To comply with PEP8, method names now use underscores.
|
||||
# Deprecated method names are re-mapped for backwards compatibility.
|
||||
self.setBody = self.set_body
|
||||
self.getBody = self.get_body
|
||||
self.delBody = self.del_body
|
||||
|
||||
return ElementBase.setup(self, xml)
|
||||
|
||||
def set_body(self, html):
|
||||
"""
|
||||
Set the contents of the HTML body.
|
||||
@@ -95,3 +78,9 @@ class HTMLIM(ElementBase):
|
||||
|
||||
|
||||
register_stanza_plugin(Message, HTMLIM)
|
||||
|
||||
# To comply with PEP8, method names now use underscores.
|
||||
# Deprecated method names are re-mapped for backwards compatibility.
|
||||
HTMLIM.setBody = HTMLIM.set_body
|
||||
HTMLIM.getBody = HTMLIM.get_body
|
||||
HTMLIM.delBody = HTMLIM.del_body
|
||||
|
||||
@@ -75,13 +75,6 @@ class Iq(RootStanza):
|
||||
Overrides StanzaBase.__init__.
|
||||
"""
|
||||
StanzaBase.__init__(self, *args, **kwargs)
|
||||
# To comply with PEP8, method names now use underscores.
|
||||
# Deprecated method names are re-mapped for backwards compatibility.
|
||||
self.setPayload = self.set_payload
|
||||
self.getQuery = self.get_query
|
||||
self.setQuery = self.set_query
|
||||
self.delQuery = self.del_query
|
||||
|
||||
if self['id'] == '':
|
||||
if self.stream is not None:
|
||||
self['id'] = self.stream.getNewId()
|
||||
@@ -229,3 +222,11 @@ class Iq(RootStanza):
|
||||
else:
|
||||
StanzaBase._set_stanza_values(self, values)
|
||||
return self
|
||||
|
||||
|
||||
# To comply with PEP8, method names now use underscores.
|
||||
# Deprecated method names are re-mapped for backwards compatibility.
|
||||
Iq.setPayload = Iq.set_payload
|
||||
Iq.getQuery = Iq.get_query
|
||||
Iq.setQuery = Iq.set_query
|
||||
Iq.delQuery = Iq.del_query
|
||||
|
||||
@@ -63,27 +63,6 @@ class Message(RootStanza):
|
||||
plugin_attrib = name
|
||||
types = set((None, 'normal', 'chat', 'headline', 'error', 'groupchat'))
|
||||
|
||||
def setup(self, xml=None):
|
||||
"""
|
||||
Populate the stanza object using an optional XML object.
|
||||
|
||||
Overrides StanzaBase.setup.
|
||||
|
||||
Arguments:
|
||||
xml -- Use an existing XML object for the stanza's values.
|
||||
"""
|
||||
# To comply with PEP8, method names now use underscores.
|
||||
# Deprecated method names are re-mapped for backwards compatibility.
|
||||
self.getType = self.get_type
|
||||
self.getMucroom = self.get_mucroom
|
||||
self.setMucroom = self.set_mucroom
|
||||
self.delMucroom = self.del_mucroom
|
||||
self.getMucnick = self.get_mucnick
|
||||
self.setMucnick = self.set_mucnick
|
||||
self.delMucnick = self.del_mucnick
|
||||
|
||||
return StanzaBase.setup(self, xml)
|
||||
|
||||
def get_type(self):
|
||||
"""
|
||||
Return the message type.
|
||||
@@ -165,3 +144,14 @@ class Message(RootStanza):
|
||||
def del_mucnick(self):
|
||||
"""Dummy method to prevent deletion."""
|
||||
pass
|
||||
|
||||
|
||||
# To comply with PEP8, method names now use underscores.
|
||||
# Deprecated method names are re-mapped for backwards compatibility.
|
||||
Message.getType = Message.get_type
|
||||
Message.getMucroom = Message.get_mucroom
|
||||
Message.setMucroom = Message.set_mucroom
|
||||
Message.delMucroom = Message.del_mucroom
|
||||
Message.getMucnick = Message.get_mucnick
|
||||
Message.setMucnick = Message.set_mucnick
|
||||
Message.delMucnick = Message.del_mucnick
|
||||
|
||||
@@ -49,23 +49,6 @@ class Nick(ElementBase):
|
||||
plugin_attrib = name
|
||||
interfaces = set(('nick',))
|
||||
|
||||
def setup(self, xml=None):
|
||||
"""
|
||||
Populate the stanza object using an optional XML object.
|
||||
|
||||
Overrides StanzaBase.setup.
|
||||
|
||||
Arguments:
|
||||
xml -- Use an existing XML object for the stanza's values.
|
||||
"""
|
||||
# To comply with PEP8, method names now use underscores.
|
||||
# Deprecated method names are re-mapped for backwards compatibility.
|
||||
self.setNick = self.set_nick
|
||||
self.getNick = self.get_nick
|
||||
self.delNick = self.del_nick
|
||||
|
||||
return ElementBase.setup(self, xml)
|
||||
|
||||
def set_nick(self, nick):
|
||||
"""
|
||||
Add a <nick> element with the given nickname.
|
||||
@@ -87,3 +70,9 @@ class Nick(ElementBase):
|
||||
|
||||
register_stanza_plugin(Message, Nick)
|
||||
register_stanza_plugin(Presence, Nick)
|
||||
|
||||
# To comply with PEP8, method names now use underscores.
|
||||
# Deprecated method names are re-mapped for backwards compatibility.
|
||||
Nick.setNick = Nick.set_nick
|
||||
Nick.getNick = Nick.get_nick
|
||||
Nick.delNick = Nick.del_nick
|
||||
|
||||
@@ -72,26 +72,6 @@ class Presence(RootStanza):
|
||||
'subscribed', 'unsubscribe', 'unsubscribed'))
|
||||
showtypes = set(('dnd', 'chat', 'xa', 'away'))
|
||||
|
||||
def setup(self, xml=None):
|
||||
"""
|
||||
Populate the stanza object using an optional XML object.
|
||||
|
||||
Overrides ElementBase.setup.
|
||||
|
||||
Arguments:
|
||||
xml -- Use an existing XML object for the stanza's values.
|
||||
"""
|
||||
# To comply with PEP8, method names now use underscores.
|
||||
# Deprecated method names are re-mapped for backwards compatibility.
|
||||
self.setShow = self.set_show
|
||||
self.getType = self.get_type
|
||||
self.setType = self.set_type
|
||||
self.delType = self.get_type
|
||||
self.getPriority = self.get_priority
|
||||
self.setPriority = self.set_priority
|
||||
|
||||
return StanzaBase.setup(self, xml)
|
||||
|
||||
def exception(self, e):
|
||||
"""
|
||||
Override exception passback for presence.
|
||||
@@ -188,3 +168,13 @@ class Presence(RootStanza):
|
||||
elif self['type'] == 'subscribe':
|
||||
self['type'] = 'subscribed'
|
||||
return StanzaBase.reply(self, clear)
|
||||
|
||||
|
||||
# To comply with PEP8, method names now use underscores.
|
||||
# Deprecated method names are re-mapped for backwards compatibility.
|
||||
Presence.setShow = Presence.set_show
|
||||
Presence.getType = Presence.get_type
|
||||
Presence.setType = Presence.set_type
|
||||
Presence.delType = Presence.get_type
|
||||
Presence.getPriority = Presence.get_priority
|
||||
Presence.setPriority = Presence.set_priority
|
||||
|
||||
@@ -38,23 +38,6 @@ class Roster(ElementBase):
|
||||
plugin_attrib = 'roster'
|
||||
interfaces = set(('items',))
|
||||
|
||||
def setup(self, xml=None):
|
||||
"""
|
||||
Populate the stanza object using an optional XML object.
|
||||
|
||||
Overrides StanzaBase.setup.
|
||||
|
||||
Arguments:
|
||||
xml -- Use an existing XML object for the stanza's values.
|
||||
"""
|
||||
# To comply with PEP8, method names now use underscores.
|
||||
# Deprecated method names are re-mapped for backwards compatibility.
|
||||
self.setItems = self.set_items
|
||||
self.getItems = self.get_items
|
||||
self.delItems = self.del_items
|
||||
|
||||
return ElementBase.setup(self, xml)
|
||||
|
||||
def set_items(self, items):
|
||||
"""
|
||||
Set the roster entries in the <roster> stanza.
|
||||
@@ -123,3 +106,9 @@ class Roster(ElementBase):
|
||||
|
||||
|
||||
register_stanza_plugin(Iq, Roster)
|
||||
|
||||
# To comply with PEP8, method names now use underscores.
|
||||
# Deprecated method names are re-mapped for backwards compatibility.
|
||||
Roster.setItems = Roster.set_items
|
||||
Roster.getItems = Roster.get_items
|
||||
Roster.delItems = Roster.del_items
|
||||
|
||||
Reference in New Issue
Block a user