Mercurial > libervia-backend
diff src/tmp/wokkel/mam.py @ 1423:882e5fabf68c
plugin groupblog, tmp (mam, rsm): some style improvments/fixes:
- renamed variables nammed after reserved word/module
- removed class variables which are not needed
- removed external parenthesis from asserts
- in mam.MAMPrefs, removed default value for default argument, as None can't be used
- (groupblog) extended docstring for DeferredItems and DeferredItemsFromMany
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 23 Apr 2015 13:35:21 +0200 |
parents | be1fccf4854d |
children | 2d8fccec84e8 |
line wrap: on
line diff
--- a/src/tmp/wokkel/mam.py Thu Apr 23 10:57:40 2015 +0200 +++ b/src/tmp/wokkel/mam.py Thu Apr 23 13:35:21 2015 +0200 @@ -85,15 +85,11 @@ @itype form: C{unicode} """ - form = None - rsm = None - node = None - - def __init__(self, form=None, rsm=None, node=None): + def __init__(self, form=None, rsm_=None, node=None): if form is not None: - assert(form.formType == 'submit') + assert form.formType == 'submit' self.form = form - self.rsm = rsm + self.rsm = rsm_ self.node = node @classmethod @@ -141,7 +137,7 @@ @return: MAM request element. @rtype: L{Element<twisted.words.xish.domish.Element>} """ - assert(parent.name == 'iq') + assert parent.name == 'iq' mam_elt = self.toElement() parent.addChild(mam_elt) return mam_elt @@ -152,7 +148,7 @@ A Message Archive Management <prefs/> request. @param default: A value in ('always', 'never', 'roster'). - @type : C{unicode} + @type : C{unicode} or C{None} @param always (list): A list of JID instances. @type always: C{list} @@ -161,24 +157,19 @@ @type never: C{list} """ - default = None - always = None - never = None - - def __init__(self, default=None, always=None, never=None): - if default: - assert(default in ('always', 'never', 'roster')) - self.default = default - if always: - assert(isinstance(always, list)) - self.always = always + def __init__(self, default, always=None, never=None): + assert default in ('always', 'never', 'roster') + self.default = default + if always is not None: + assert isinstance(always, list) else: - self.always = [] - if never: - assert(isinstance(never, list)) - self.never = never + always = [] + self.always = always + if never is not None: + assert isinstance(never, list) else: - self.never = [] + never = [] + self.never = never @classmethod def parse(cls, element): @@ -229,7 +220,7 @@ @return: MAM request element. @rtype: L{Element<twisted.words.xish.domish.Element>} """ - assert(parent.name == 'iq') + assert parent.name == 'iq' mam_elt = self.toElement() parent.addChild(mam_elt) return mam_elt @@ -329,7 +320,7 @@ @rtype: L{Deferred<twisted.internet.defer.Deferred>} """ # http://xmpp.org/extensions/xep-0313.html#prefs - assert(default is not None) + assert default is not None iq = IQ(self.xmlstream, 'set') MAMPrefs(default, always, never).render(iq) if sender is not None: @@ -408,14 +399,13 @@ }, } - extra_filters = {} - def __init__(self, resource): """ @param resource: instance implementing IMAMResource @type resource: L{object} """ self.resource = resource + self.extra_filters = {} def connectionInitialized(self): """