diff options
Diffstat (limited to 'sleekxmpp/plugins')
36 files changed, 146 insertions, 145 deletions
diff --git a/sleekxmpp/plugins/base.py b/sleekxmpp/plugins/base.py index 9a7e1b19..5a298b72 100644 --- a/sleekxmpp/plugins/base.py +++ b/sleekxmpp/plugins/base.py @@ -31,10 +31,10 @@ log = logging.getLogger(__name__) PLUGIN_REGISTRY = {} #: In order to do cascading plugin disabling, reverse dependencies -#: must be tracked. +#: must be tracked. PLUGIN_DEPENDENTS = {} -#: Only allow one thread to manipulate the plugin registry at a time. +#: Only allow one thread to manipulate the plugin registry at a time. REGISTRY_LOCK = threading.RLock() @@ -75,7 +75,7 @@ def load_plugin(name, module=None): plugins are in packages matching their name, even though the plugin class name does not have to match. - :param str module: The name of the base module to search + :param str module: The name of the base module to search for the plugin. """ try: @@ -107,7 +107,7 @@ def load_plugin(name, module=None): log.exception("Unable to load plugin: %s", name) -class PluginManager(object): +class PluginManager(object): def __init__(self, xmpp, config=None): #: We will track all enabled plugins in a set so that we #: can enable plugins in batches and pull in dependencies @@ -181,7 +181,7 @@ class PluginManager(object): def enable_all(self, names=None, config=None): """Enable all registered plugins. - + :param list names: A list of plugin names to enable. If none are provided, all registered plugins will be enabled. @@ -292,7 +292,7 @@ class BasePlugin(object): def post_init(self): """Initialize any cross-plugin state. - + Only needed if the plugin has circular dependencies. """ pass diff --git a/sleekxmpp/plugins/xep_0027/gpg.py b/sleekxmpp/plugins/xep_0027/gpg.py index ccc7c400..7cc128bd 100644 --- a/sleekxmpp/plugins/xep_0027/gpg.py +++ b/sleekxmpp/plugins/xep_0027/gpg.py @@ -81,7 +81,8 @@ class XEP_0027(BasePlugin): def _sign_presence(self, stanza): if isinstance(stanza, Presence): - if stanza['type'] == 'available' or stanza['type'] in Presence.showtypes: + if stanza['type'] == 'available' or \ + stanza['type'] in Presence.showtypes: stanza['signed'] = stanza['status'] return stanza diff --git a/sleekxmpp/plugins/xep_0027/stanza.py b/sleekxmpp/plugins/xep_0027/stanza.py index 927693ad..3170ca6e 100644 --- a/sleekxmpp/plugins/xep_0027/stanza.py +++ b/sleekxmpp/plugins/xep_0027/stanza.py @@ -51,6 +51,3 @@ class Encrypted(ElementBase): if self.xml.text: return xmpp['xep_0027'].decrypt(self.xml.text, parent['to']) return None - - - diff --git a/sleekxmpp/plugins/xep_0030/disco.py b/sleekxmpp/plugins/xep_0030/disco.py index a66ab935..18c1dba2 100644 --- a/sleekxmpp/plugins/xep_0030/disco.py +++ b/sleekxmpp/plugins/xep_0030/disco.py @@ -339,8 +339,8 @@ class XEP_0030(BasePlugin): if local: log.debug("Looking up local disco#info data " + \ "for %s, node %s.", jid, node) - info = self.api['get_info'](jid, node, - kwargs.get('ifrom', None), + info = self.api['get_info'](jid, node, + kwargs.get('ifrom', None), kwargs) info = self._fix_default_info(info) return self._wrap(kwargs.get('ifrom', None), jid, info) @@ -348,8 +348,8 @@ class XEP_0030(BasePlugin): if cached: log.debug("Looking up cached disco#info data " + \ "for %s, node %s.", jid, node) - info = self.api['get_cached_info'](jid, node, - kwargs.get('ifrom', None), + info = self.api['get_cached_info'](jid, node, + kwargs.get('ifrom', None), kwargs) if info is not None: return self._wrap(kwargs.get('ifrom', None), jid, info) @@ -405,8 +405,8 @@ class XEP_0030(BasePlugin): Otherwise the parameter is ignored. """ if local or jid is None: - items = self.api['get_items'](jid, node, - kwargs.get('ifrom', None), + items = self.api['get_items'](jid, node, + kwargs.get('ifrom', None), kwargs) return self._wrap(kwargs.get('ifrom', None), jid, items) diff --git a/sleekxmpp/plugins/xep_0033/stanza.py b/sleekxmpp/plugins/xep_0033/stanza.py index 501f6fa6..1ff9fb20 100644 --- a/sleekxmpp/plugins/xep_0033/stanza.py +++ b/sleekxmpp/plugins/xep_0033/stanza.py @@ -16,7 +16,7 @@ class Addresses(ElementBase): plugin_attrib = 'addresses' interfaces = set() - def add_address(self, atype='to', jid='', node='', uri='', + def add_address(self, atype='to', jid='', node='', uri='', desc='', delivered=False): addr = Address(parent=self) addr['type'] = atype @@ -116,7 +116,7 @@ for atype in ('all', 'bcc', 'cc', 'noreply', 'replyroom', 'replyto', 'to'): setattr(Addresses, "get_%s" % atype, get_multi) setattr(Addresses, "set_%s" % atype, set_multi) setattr(Addresses, "del_%s" % atype, del_multi) - + # To retain backwards compatibility: setattr(Addresses, "get%s" % atype.title(), get_multi) setattr(Addresses, "set%s" % atype.title(), set_multi) diff --git a/sleekxmpp/plugins/xep_0054/stanza.py b/sleekxmpp/plugins/xep_0054/stanza.py index 7d9bc520..75b69d3e 100644 --- a/sleekxmpp/plugins/xep_0054/stanza.py +++ b/sleekxmpp/plugins/xep_0054/stanza.py @@ -106,8 +106,8 @@ class Address(ElementBase): namespace = 'vcard-temp' plugin_attrib = name plugin_multi_attrib = 'addresses' - interfaces = set(['HOME', 'WORK', 'POSTAL', 'PARCEL', 'DOM', 'INTL', - 'PREF', 'POBOX', 'EXTADD', 'STREET', 'LOCALITY', + interfaces = set(['HOME', 'WORK', 'POSTAL', 'PARCEL', 'DOM', 'INTL', + 'PREF', 'POBOX', 'EXTADD', 'STREET', 'LOCALITY', 'REGION', 'PCODE', 'CTRY']) sub_interfaces = set(['POBOX', 'EXTADD', 'STREET', 'LOCALITY', 'REGION', 'PCODE', 'CTRY']) @@ -123,8 +123,8 @@ class Telephone(ElementBase): 'CELL', 'VIDEO', 'BBS', 'MODEM', 'ISDN', 'PCS', 'PREF', 'NUMBER']) sub_interfaces = set(['NUMBER']) - bool_interfaces = set(['HOME', 'WORK', 'VOICE', 'FAX', 'PAGER', - 'MSG', 'CELL', 'VIDEO', 'BBS', 'MODEM', + bool_interfaces = set(['HOME', 'WORK', 'VOICE', 'FAX', 'PAGER', + 'MSG', 'CELL', 'VIDEO', 'BBS', 'MODEM', 'ISDN', 'PCS', 'PREF']) def setup(self, xml=None): @@ -145,7 +145,7 @@ class Label(ElementBase): plugin_multi_attrib = 'labels' interfaces = set(['HOME', 'WORK', 'POSTAL', 'PARCEL', 'DOM', 'INT', 'PREF', 'lines']) - bool_interfaces = set(['HOME', 'WORK', 'POSTAL', 'PARCEL', 'DOM', + bool_interfaces = set(['HOME', 'WORK', 'POSTAL', 'PARCEL', 'DOM', 'INT', 'PREF']) def add_line(self, value): @@ -515,7 +515,7 @@ class TimeZone(ElementBase): is_extension = True def set_tz(self, value): - time = xep_0082.time(offset=value) + time = xep_0082.time(offset=value) if time[-1] == 'Z': self.xml.text = 'Z' else: diff --git a/sleekxmpp/plugins/xep_0054/vcard_temp.py b/sleekxmpp/plugins/xep_0054/vcard_temp.py index 45d3c74c..672f948a 100644 --- a/sleekxmpp/plugins/xep_0054/vcard_temp.py +++ b/sleekxmpp/plugins/xep_0054/vcard_temp.py @@ -53,7 +53,7 @@ class XEP_0054(BasePlugin): def make_vcard(self): return VCardTemp() - def get_vcard(self, jid=None, ifrom=None, local=False, cached=False, + def get_vcard(self, jid=None, ifrom=None, local=False, cached=False, block=True, callback=None, timeout=None): if self.xmpp.is_component and jid.domain == self.xmpp.boundjid.domain: local = True @@ -84,12 +84,12 @@ class XEP_0054(BasePlugin): iq.enable('vcard_temp') vcard = iq.send(block=block, callback=callback, timeout=timeout) - + if block: self.api['set_vcard'](vcard['from'], args=vcard['vcard_temp']) return vcard - def publish_vcard(self, vcard=None, jid=None, block=True, ifrom=None, + def publish_vcard(self, vcard=None, jid=None, block=True, ifrom=None, callback=None, timeout=None): if self.xmpp.is_component: self.api['set_vcard'](jid, None, ifrom, vcard) diff --git a/sleekxmpp/plugins/xep_0078/stanza.py b/sleekxmpp/plugins/xep_0078/stanza.py index 86ba09ad..c8b26071 100644 --- a/sleekxmpp/plugins/xep_0078/stanza.py +++ b/sleekxmpp/plugins/xep_0078/stanza.py @@ -39,5 +39,3 @@ class AuthFeature(ElementBase): interfaces = set() plugin_tag_map = {} plugin_attrib_map = {} - - diff --git a/sleekxmpp/plugins/xep_0080/geoloc.py b/sleekxmpp/plugins/xep_0080/geoloc.py index 20dde4dd..28c69a2d 100644 --- a/sleekxmpp/plugins/xep_0080/geoloc.py +++ b/sleekxmpp/plugins/xep_0080/geoloc.py @@ -40,33 +40,33 @@ class XEP_0080(BasePlugin): accuracy -- Horizontal GPS error in meters. alt -- Altitude in meters above or below sea level. area -- A named area such as a campus or neighborhood. - bearing -- GPS bearing (direction in which the entity is - heading to reach its next waypoint), measured in + bearing -- GPS bearing (direction in which the entity is + heading to reach its next waypoint), measured in decimal degrees relative to true north. building -- A specific building on a street or in an area. country -- The nation where the user is located. countrycode -- The ISO 3166 two-letter country code. datum -- GPS datum. - description -- A natural-language name for or description of + description -- A natural-language name for or description of the location. error -- Horizontal GPS error in arc minutes. Obsoleted by the accuracy parameter. floor -- A particular floor in a building. lat -- Latitude in decimal degrees North. - locality -- A locality within the administrative region, such + locality -- A locality within the administrative region, such as a town or city. lon -- Longitude in decimal degrees East. postalcode -- A code used for postal delivery. - region -- An administrative region of the nation, such + region -- An administrative region of the nation, such as a state or province. room -- A particular room in a building. - speed -- The speed at which the entity is moving, + speed -- The speed at which the entity is moving, in meters per second. street -- A thoroughfare within the locality, or a crossing of two thoroughfares. - text -- A catch-all element that captures any other + text -- A catch-all element that captures any other information about the location. - timestamp -- UTC timestamp specifying the moment when the + timestamp -- UTC timestamp specifying the moment when the reading was taken. uri -- A URI or URL pointing to information about the location. @@ -115,7 +115,7 @@ class XEP_0080(BasePlugin): be executed when a reply stanza is received. """ geoloc = Geoloc() - return self.xmpp['xep_0163'].publish(geoloc, + return self.xmpp['xep_0163'].publish(geoloc, ifrom=ifrom, block=block, callback=callback, diff --git a/sleekxmpp/plugins/xep_0080/stanza.py b/sleekxmpp/plugins/xep_0080/stanza.py index a83a8b1b..8f466516 100644 --- a/sleekxmpp/plugins/xep_0080/stanza.py +++ b/sleekxmpp/plugins/xep_0080/stanza.py @@ -31,33 +31,33 @@ class Geoloc(ElementBase): accuracy -- Horizontal GPS error in meters. alt -- Altitude in meters above or below sea level. area -- A named area such as a campus or neighborhood. - bearing -- GPS bearing (direction in which the entity is - heading to reach its next waypoint), measured in + bearing -- GPS bearing (direction in which the entity is + heading to reach its next waypoint), measured in decimal degrees relative to true north. building -- A specific building on a street or in an area. country -- The nation where the user is located. countrycode -- The ISO 3166 two-letter country code. datum -- GPS datum. - description -- A natural-language name for or description of + description -- A natural-language name for or description of the location. error -- Horizontal GPS error in arc minutes. Obsoleted by the accuracy parameter. floor -- A particular floor in a building. lat -- Latitude in decimal degrees North. - locality -- A locality within the administrative region, such + locality -- A locality within the administrative region, such as a town or city. lon -- Longitude in decimal degrees East. postalcode -- A code used for postal delivery. - region -- An administrative region of the nation, such + region -- An administrative region of the nation, such as a state or province. room -- A particular room in a building. - speed -- The speed at which the entity is moving, + speed -- The speed at which the entity is moving, in meters per second. street -- A thoroughfare within the locality, or a crossing of two thoroughfares. - text -- A catch-all element that captures any other + text -- A catch-all element that captures any other information about the location. - timestamp -- UTC timestamp specifying the moment when the + timestamp -- UTC timestamp specifying the moment when the reading was taken. uri -- A URI or URL pointing to information about the location. @@ -65,10 +65,10 @@ class Geoloc(ElementBase): namespace = 'http://jabber.org/protocol/geoloc' name = 'geoloc' - interfaces = set(('accuracy', 'alt', 'area', 'bearing', 'building', - 'country', 'countrycode', 'datum', 'dscription', - 'error', 'floor', 'lat', 'locality', 'lon', - 'postalcode', 'region', 'room', 'speed', 'street', + interfaces = set(('accuracy', 'alt', 'area', 'bearing', 'building', + 'country', 'countrycode', 'datum', 'dscription', + 'error', 'floor', 'lat', 'locality', 'lon', + 'postalcode', 'region', 'room', 'speed', 'street', 'text', 'timestamp', 'uri')) sub_interfaces = interfaces plugin_attrib = name @@ -88,7 +88,7 @@ class Geoloc(ElementBase): """ self._set_sub_text('accuracy', text=str(accuracy)) return self - + def get_accuracy(self): """ Return the value of the <accuracy> element as an integer. @@ -111,7 +111,7 @@ class Geoloc(ElementBase): """ self._set_sub_text('alt', text=str(alt)) return self - + def get_alt(self): """ Return the value of the <alt> element as an integer. @@ -130,8 +130,8 @@ class Geoloc(ElementBase): Set the value of the <bearing> element. Arguments: - bearing -- GPS bearing (direction in which the entity is heading - to reach its next waypoint), measured in decimal + bearing -- GPS bearing (direction in which the entity is heading + to reach its next waypoint), measured in decimal degrees relative to true north """ self._set_sub_text('bearing', text=str(bearing)) @@ -155,7 +155,7 @@ class Geoloc(ElementBase): Set the value of the <error> element. Arguments: - error -- Horizontal GPS error in arc minutes; this + error -- Horizontal GPS error in arc minutes; this element is deprecated in favor of <accuracy/> """ self._set_sub_text('error', text=str(error)) @@ -183,7 +183,7 @@ class Geoloc(ElementBase): """ self._set_sub_text('lat', text=str(lat)) return self - + def get_lat(self): """ Return the value of the <lat> element as a float. @@ -196,7 +196,7 @@ class Geoloc(ElementBase): return float(p) except ValueError: return None - + def set_lon(self, lon): """ Set the value of the <lon> element. @@ -225,12 +225,12 @@ class Geoloc(ElementBase): Set the value of the <speed> element. Arguments: - speed -- The speed at which the entity is moving, + speed -- The speed at which the entity is moving, in meters per second """ self._set_sub_text('speed', text=str(speed)) return self - + def get_speed(self): """ Return the value of the <speed> element as a float. diff --git a/sleekxmpp/plugins/xep_0082.py b/sleekxmpp/plugins/xep_0082.py index 96eb331a..02571fa7 100644 --- a/sleekxmpp/plugins/xep_0082.py +++ b/sleekxmpp/plugins/xep_0082.py @@ -42,6 +42,7 @@ def format_date(time_obj): time_obj = time_obj.date() return time_obj.isoformat() + def format_time(time_obj): """ Return a formatted string version of a time object. @@ -60,6 +61,7 @@ def format_time(time_obj): return '%sZ' % timestamp return timestamp + def format_datetime(time_obj): """ Return a formatted string version of a datetime object. @@ -76,6 +78,7 @@ def format_datetime(time_obj): return '%sZ' % timestamp return timestamp + def date(year=None, month=None, day=None, obj=False): """ Create a date only timestamp for the given instant. @@ -98,9 +101,10 @@ def date(year=None, month=None, day=None, obj=False): day = today.day value = dt.date(year, month, day) if obj: - return value + return value return format_date(value) + def time(hour=None, min=None, sec=None, micro=None, offset=None, obj=False): """ Create a time only timestamp for the given instant. @@ -136,6 +140,7 @@ def time(hour=None, min=None, sec=None, micro=None, offset=None, obj=False): return value return format_time(value) + def datetime(year=None, month=None, day=None, hour=None, min=None, sec=None, micro=None, offset=None, separators=True, obj=False): @@ -181,7 +186,7 @@ def datetime(year=None, month=None, day=None, hour=None, value = dt.datetime(year, month, day, hour, min, sec, micro, offset) if obj: - return value + return value return format_datetime(value) diff --git a/sleekxmpp/plugins/xep_0084/__init__.py b/sleekxmpp/plugins/xep_0084/__init__.py index 39aa8d76..6b87573f 100644 --- a/sleekxmpp/plugins/xep_0084/__init__.py +++ b/sleekxmpp/plugins/xep_0084/__init__.py @@ -14,5 +14,3 @@ from sleekxmpp.plugins.xep_0084.avatar import XEP_0084 register_plugin(XEP_0084) - - diff --git a/sleekxmpp/plugins/xep_0084/avatar.py b/sleekxmpp/plugins/xep_0084/avatar.py index c5f8e4de..14ab7d97 100644 --- a/sleekxmpp/plugins/xep_0084/avatar.py +++ b/sleekxmpp/plugins/xep_0084/avatar.py @@ -38,7 +38,7 @@ class XEP_0084(BasePlugin): def retrieve_avatar(self, jid, id, url=None, ifrom=None, block=True, callback=None, timeout=None): - return self.xmpp['xep_0060'].get_item(jid, Data.namespace, id, + return self.xmpp['xep_0060'].get_item(jid, Data.namespace, id, ifrom=ifrom, block=block, callback=callback, diff --git a/sleekxmpp/plugins/xep_0086/stanza.py b/sleekxmpp/plugins/xep_0086/stanza.py index 6554d249..d4909806 100644 --- a/sleekxmpp/plugins/xep_0086/stanza.py +++ b/sleekxmpp/plugins/xep_0086/stanza.py @@ -47,28 +47,28 @@ class LegacyError(ElementBase): interfaces = set(('condition',)) overrides = ['set_condition'] - error_map = {'bad-request': ('modify','400'), - 'conflict': ('cancel','409'), - 'feature-not-implemented': ('cancel','501'), - 'forbidden': ('auth','403'), - 'gone': ('modify','302'), - 'internal-server-error': ('wait','500'), - 'item-not-found': ('cancel','404'), - 'jid-malformed': ('modify','400'), - 'not-acceptable': ('modify','406'), - 'not-allowed': ('cancel','405'), - 'not-authorized': ('auth','401'), - 'payment-required': ('auth','402'), - 'recipient-unavailable': ('wait','404'), - 'redirect': ('modify','302'), - 'registration-required': ('auth','407'), - 'remote-server-not-found': ('cancel','404'), - 'remote-server-timeout': ('wait','504'), - 'resource-constraint': ('wait','500'), - 'service-unavailable': ('cancel','503'), - 'subscription-required': ('auth','407'), - 'undefined-condition': (None,'500'), - 'unexpected-request': ('wait','400')} + error_map = {'bad-request': ('modify', '400'), + 'conflict': ('cancel', '409'), + 'feature-not-implemented': ('cancel', '501'), + 'forbidden': ('auth', '403'), + 'gone': ('modify', '302'), + 'internal-server-error': ('wait', '500'), + 'item-not-found': ('cancel', '404'), + 'jid-malformed': ('modify', '400'), + 'not-acceptable': ('modify', '406'), + 'not-allowed': ('cancel', '405'), + 'not-authorized': ('auth', '401'), + 'payment-required': ('auth', '402'), + 'recipient-unavailable': ('wait', '404'), + 'redirect': ('modify', '302'), + 'registration-required': ('auth', '407'), + 'remote-server-not-found': ('cancel', '404'), + 'remote-server-timeout': ('wait', '504'), + 'resource-constraint': ('wait', '500'), + 'service-unavailable': ('cancel', '503'), + 'subscription-required': ('auth', '407'), + 'undefined-condition': (None, '500'), + 'unexpected-request': ('wait', '400')} def setup(self, xml): """Don't create XML for the plugin.""" diff --git a/sleekxmpp/plugins/xep_0107/user_mood.py b/sleekxmpp/plugins/xep_0107/user_mood.py index 11aaace4..95e17d45 100644 --- a/sleekxmpp/plugins/xep_0107/user_mood.py +++ b/sleekxmpp/plugins/xep_0107/user_mood.py @@ -34,7 +34,7 @@ class XEP_0107(BasePlugin): register_stanza_plugin(Message, UserMood) self.xmpp['xep_0163'].register_pep('user_mood', UserMood) - def publish_mood(self, value=None, text=None, options=None, + def publish_mood(self, value=None, text=None, options=None, ifrom=None, block=True, callback=None, timeout=None): """ Publish the user's current mood. @@ -79,7 +79,7 @@ class XEP_0107(BasePlugin): be executed when a reply stanza is received. """ mood = UserMood() - return self.xmpp['xep_0163'].publish(mood, + return self.xmpp['xep_0163'].publish(mood, node=UserMood.namespace, ifrom=ifrom, block=block, diff --git a/sleekxmpp/plugins/xep_0108/stanza.py b/sleekxmpp/plugins/xep_0108/stanza.py index 4dc18f43..4650160a 100644 --- a/sleekxmpp/plugins/xep_0108/stanza.py +++ b/sleekxmpp/plugins/xep_0108/stanza.py @@ -21,7 +21,7 @@ class UserActivity(ElementBase): 'talking', 'traveling', 'undefined', 'working']) specific = set(['at_the_spa', 'brushing_teeth', 'buying_groceries', 'cleaning', 'coding', 'commuting', 'cooking', 'cycling', - 'dancing', 'day_off', 'doing_maintenance', + 'dancing', 'day_off', 'doing_maintenance', 'doing_the_dishes', 'doing_the_laundry', 'driving', 'fishing', 'gaming', 'gardening', 'getting_a_haircut', 'going_out', 'hanging_out', 'having_a_beer', @@ -31,11 +31,11 @@ class UserActivity(ElementBase): 'jogging', 'on_a_bus', 'on_a_plane', 'on_a_train', 'on_a_trip', 'on_the_phone', 'on_vacation', 'on_video_phone', 'other', 'partying', 'playing_sports', - 'praying', 'reading', 'rehearsing', 'running', + 'praying', 'reading', 'rehearsing', 'running', 'running_an_errand', 'scheduled_holiday', 'shaving', 'shopping', 'skiing', 'sleeping', 'smoking', 'socializing', 'studying', 'sunbathing', 'swimming', - 'taking_a_bath', 'taking_a_shower', 'thinking', + 'taking_a_bath', 'taking_a_shower', 'thinking', 'walking', 'walking_the_dog', 'watching_a_movie', 'watching_tv', 'working_out', 'writing']) @@ -46,7 +46,7 @@ class UserActivity(ElementBase): if isinstance(value, tuple) or isinstance(value, list): general = value[0] specific = value[1] - + if general in self.general: gen_xml = ET.Element('{%s}%s' % (self.namespace, general)) if specific: diff --git a/sleekxmpp/plugins/xep_0108/user_activity.py b/sleekxmpp/plugins/xep_0108/user_activity.py index 43270486..cd4f48d1 100644 --- a/sleekxmpp/plugins/xep_0108/user_activity.py +++ b/sleekxmpp/plugins/xep_0108/user_activity.py @@ -29,7 +29,7 @@ class XEP_0108(BasePlugin): def plugin_init(self): self.xmpp['xep_0163'].register_pep('user_activity', UserActivity) - def publish_activity(self, general, specific=None, text=None, options=None, + def publish_activity(self, general, specific=None, text=None, options=None, ifrom=None, block=True, callback=None, timeout=None): """ Publish the user's current activity. @@ -76,7 +76,7 @@ class XEP_0108(BasePlugin): be executed when a reply stanza is received. """ activity = UserActivity() - return self.xmpp['xep_0163'].publish(activity, + return self.xmpp['xep_0163'].publish(activity, node=UserActivity.namespace, ifrom=ifrom, block=block, diff --git a/sleekxmpp/plugins/xep_0115/caps.py b/sleekxmpp/plugins/xep_0115/caps.py index 5e5d2320..b0cba42d 100644 --- a/sleekxmpp/plugins/xep_0115/caps.py +++ b/sleekxmpp/plugins/xep_0115/caps.py @@ -35,7 +35,7 @@ class XEP_0115(BasePlugin): stanza = stanza def plugin_init(self): - self.hashes = {'sha-1': hashlib.sha1, + self.hashes = {'sha-1': hashlib.sha1, 'sha1': hashlib.sha1, 'md5': hashlib.md5} @@ -124,7 +124,7 @@ class XEP_0115(BasePlugin): existing_verstring = self.get_verstring(pres['from'].full) if str(existing_verstring) == str(pres['caps']['ver']): return - + if pres['caps']['hash'] not in self.hashes: try: log.debug("Unknown caps hash: %s", pres['caps']['hash']) @@ -132,7 +132,7 @@ class XEP_0115(BasePlugin): return except XMPPError: return - + log.debug("New caps verification string: %s", pres['caps']['ver']) try: node = '%s#%s' % (pres['caps']['node'], pres['caps']['ver']) @@ -140,7 +140,7 @@ class XEP_0115(BasePlugin): if isinstance(caps, Iq): caps = caps['disco_info'] - + if self._validate_caps(caps, pres['caps']['hash'], pres['caps']['ver']): self.assign_verstring(pres['from'], pres['caps']['ver']) @@ -173,7 +173,8 @@ class XEP_0115(BasePlugin): form_types.append(f_type) deduped_form_types.add(f_type) if len(form_types) != len(deduped_form_types): - log.debug("Duplicated FORM_TYPE values, invalid for caps") + log.debug("Duplicated FORM_TYPE values, " + \ + "invalid for caps") return False if len(f_type) > 1: @@ -183,7 +184,8 @@ class XEP_0115(BasePlugin): return False if stanza['fields']['FORM_TYPE']['type'] != 'hidden': - log.debug("Field FORM_TYPE type not 'hidden', ignoring form for caps") + log.debug("Field FORM_TYPE type not 'hidden', " + \ + "ignoring form for caps") caps.xml.remove(stanza.xml) else: log.debug("No FORM_TYPE found, ignoring form for caps") @@ -212,7 +214,7 @@ class XEP_0115(BasePlugin): identities = sorted(('/'.join(i) for i in identities)) features = sorted(info['features']) - + S += '<'.join(identities) + '<' S += '<'.join(features) + '<' @@ -254,7 +256,7 @@ class XEP_0115(BasePlugin): info = info['disco_info'] ver = self.generate_verstring(info, self.hash) self.xmpp['xep_0030'].set_info( - jid=jid, + jid=jid, node='%s#%s' % (self.caps_node, ver), info=info) self.cache_caps(ver, info) diff --git a/sleekxmpp/plugins/xep_0115/static.py b/sleekxmpp/plugins/xep_0115/static.py index a0a8fb23..f83c244c 100644 --- a/sleekxmpp/plugins/xep_0115/static.py +++ b/sleekxmpp/plugins/xep_0115/static.py @@ -69,7 +69,7 @@ class StaticCaps(object): return True try: - info = self.disco.get_info(jid=jid, node=node, + info = self.disco.get_info(jid=jid, node=node, ifrom=ifrom, **data) info = self.disco._wrap(ifrom, jid, info, True) return feature in info['disco_info']['features'] @@ -99,7 +99,7 @@ class StaticCaps(object): be skipped, even if a result has already been cached. Defaults to false. """ - identity = (data.get('category', None), + identity = (data.get('category', None), data.get('itype', None), data.get('lang', None)) @@ -114,7 +114,7 @@ class StaticCaps(object): return True try: - info = self.disco.get_info(jid=jid, node=node, + info = self.disco.get_info(jid=jid, node=node, ifrom=ifrom, **data) info = self.disco._wrap(ifrom, jid, info, True) return identity in map(trunc, info['disco_info']['identities']) diff --git a/sleekxmpp/plugins/xep_0118/stanza.py b/sleekxmpp/plugins/xep_0118/stanza.py index 80e0358a..3fdab284 100644 --- a/sleekxmpp/plugins/xep_0118/stanza.py +++ b/sleekxmpp/plugins/xep_0118/stanza.py @@ -14,7 +14,7 @@ class UserTune(ElementBase): name = 'tune' namespace = 'http://jabber.org/protocol/tune' plugin_attrib = 'tune' - interfaces = set(['artist', 'length', 'rating', 'source', + interfaces = set(['artist', 'length', 'rating', 'source', 'title', 'track', 'uri']) sub_interfaces = interfaces diff --git a/sleekxmpp/plugins/xep_0118/user_tune.py b/sleekxmpp/plugins/xep_0118/user_tune.py index c848eaa8..53a4f51a 100644 --- a/sleekxmpp/plugins/xep_0118/user_tune.py +++ b/sleekxmpp/plugins/xep_0118/user_tune.py @@ -30,7 +30,7 @@ class XEP_0118(BasePlugin): self.xmpp['xep_0163'].register_pep('user_tune', UserTune) def publish_tune(self, artist=None, length=None, rating=None, source=None, - title=None, track=None, uri=None, options=None, + title=None, track=None, uri=None, options=None, ifrom=None, block=True, callback=None, timeout=None): """ Publish the user's current tune. @@ -61,7 +61,7 @@ class XEP_0118(BasePlugin): tune['title'] = title tune['track'] = track tune['uri'] = uri - return self.xmpp['xep_0163'].publish(tune, + return self.xmpp['xep_0163'].publish(tune, node=UserTune.namespace, options=options, ifrom=ifrom, @@ -84,7 +84,7 @@ class XEP_0118(BasePlugin): be executed when a reply stanza is received. """ tune = UserTune() - return self.xmpp['xep_0163'].publish(tune, + return self.xmpp['xep_0163'].publish(tune, node=UserTune.namespace, ifrom=ifrom, block=block, diff --git a/sleekxmpp/plugins/xep_0153/vcard_avatar.py b/sleekxmpp/plugins/xep_0153/vcard_avatar.py index 2cc2f15a..3f36d135 100644 --- a/sleekxmpp/plugins/xep_0153/vcard_avatar.py +++ b/sleekxmpp/plugins/xep_0153/vcard_avatar.py @@ -45,7 +45,7 @@ class XEP_0153(BasePlugin): self.api.register(self._set_hash, 'set_hash', default=True) self.api.register(self._get_hash, 'get_hash', default=True) - def set_avatar(self, jid=None, avatar=None, mtype=None, block=True, + def set_avatar(self, jid=None, avatar=None, mtype=None, block=True, timeout=None, callback=None): vcard = self.xmpp['xep_0054'].get_vcard(jid, cached=True) vcard = vcard['vcard_temp'] @@ -69,7 +69,7 @@ class XEP_0153(BasePlugin): own_jid = (jid.bare == self.xmpp.boundjid.bare) if self.xmpp.is_component: own_jid = (jid.domain == self.xmpp.boundjid.domain) - + if jid is not None: jid = jid.bare self.api['set_hash'](jid, args=None) @@ -77,7 +77,7 @@ class XEP_0153(BasePlugin): self.xmpp.roster[jid].send_last_presence() iq = self.xmpp['xep_0054'].get_vcard( - jid=jid, + jid=jid, ifrom=self.xmpp.boundjid) data = iq['vcard_temp']['PHOTO']['BINVAL'] if not data: diff --git a/sleekxmpp/plugins/xep_0163.py b/sleekxmpp/plugins/xep_0163.py index 0bb67e32..43d3ad3a 100644 --- a/sleekxmpp/plugins/xep_0163.py +++ b/sleekxmpp/plugins/xep_0163.py @@ -56,7 +56,7 @@ class XEP_0163(BasePlugin): jid -- Optionally specify the JID. """ if not isinstance(namespace, set) and not isinstance(namespace, list): - namespace = [namespace] + namespace = [namespace] for ns in namespace: self.xmpp['xep_0030'].add_feature('%s+notify' % ns, @@ -75,7 +75,7 @@ class XEP_0163(BasePlugin): jid -- Optionally specify the JID. """ if not isinstance(namespace, set) and not isinstance(namespace, list): - namespace = [namespace] + namespace = [namespace] for ns in namespace: self.xmpp['xep_0030'].del_feature(jid=jid, diff --git a/sleekxmpp/plugins/xep_0172/user_nick.py b/sleekxmpp/plugins/xep_0172/user_nick.py index c20c3583..324407c3 100644 --- a/sleekxmpp/plugins/xep_0172/user_nick.py +++ b/sleekxmpp/plugins/xep_0172/user_nick.py @@ -78,7 +78,7 @@ class XEP_0172(BasePlugin): be executed when a reply stanza is received. """ nick = UserNick() - return self.xmpp['xep_0163'].publish(nick, + return self.xmpp['xep_0163'].publish(nick, node=UserNick.namespace, ifrom=ifrom, block=block, diff --git a/sleekxmpp/plugins/xep_0184/receipt.py b/sleekxmpp/plugins/xep_0184/receipt.py index c0086b03..83d89269 100644 --- a/sleekxmpp/plugins/xep_0184/receipt.py +++ b/sleekxmpp/plugins/xep_0184/receipt.py @@ -100,13 +100,13 @@ class XEP_0184(BasePlugin): if not isinstance(stanza, Message): return stanza - + if stanza['request_receipt']: return stanza if not stanza['type'] in self.ack_types: return stanza - + if stanza['receipt']: return stanza diff --git a/sleekxmpp/plugins/xep_0198/stanza.py b/sleekxmpp/plugins/xep_0198/stanza.py index 5cf93436..6461d766 100644 --- a/sleekxmpp/plugins/xep_0198/stanza.py +++ b/sleekxmpp/plugins/xep_0198/stanza.py @@ -82,7 +82,6 @@ class Resumed(StanzaBase): self._set_attr('h', str(val)) - class Failed(StanzaBase, Error): name = 'failed' namespace = 'urn:xmpp:sm:3' @@ -106,7 +105,7 @@ class StreamManagement(ElementBase): self.del_required() if val: self._set_sub_text('required', '', keep=True) - + def del_required(self): self._del_sub('required') @@ -117,7 +116,7 @@ class StreamManagement(ElementBase): self.del_optional() if val: self._set_sub_text('optional', '', keep=True) - + def del_optional(self): self._del_sub('optional') diff --git a/sleekxmpp/plugins/xep_0198/stream_management.py b/sleekxmpp/plugins/xep_0198/stream_management.py index 7045ad21..05d5856f 100644 --- a/sleekxmpp/plugins/xep_0198/stream_management.py +++ b/sleekxmpp/plugins/xep_0198/stream_management.py @@ -21,7 +21,7 @@ from sleekxmpp.plugins.xep_0198 import stanza log = logging.getLogger(__name__) -MAX_SEQ = 2**32 +MAX_SEQ = 2 ** 32 class XEP_0198(BasePlugin): @@ -69,7 +69,7 @@ class XEP_0198(BasePlugin): self.enabled = threading.Event() self.unacked_queue = collections.deque() - + self.seq_lock = threading.Lock() self.handled_lock = threading.Lock() self.ack_lock = threading.Lock() @@ -197,7 +197,7 @@ class XEP_0198(BasePlugin): def _handle_enabled(self, stanza): """Save the SM-ID, if provided. - + Raises an :term:`sm_enabled` event. """ self.xmpp.features.add('stream_management') @@ -231,7 +231,7 @@ class XEP_0198(BasePlugin): def _handle_ack(self, ack): """Process a server ack by freeing acked stanzas from the queue. - + Raises a :term:`stanza_acked` event for each acked stanza. """ if ack['h'] == self.last_ack: @@ -243,10 +243,10 @@ class XEP_0198(BasePlugin): log.debug("Ack: %s, Last Ack: %s, " + \ "Unacked: %s, Num Acked: %s, " + \ "Remaining: %s", - ack['h'], - self.last_ack, + ack['h'], + self.last_ack, num_unacked, - num_acked, + num_acked, num_unacked - num_acked) for x in range(num_acked): seq, stanza = self.unacked_queue.popleft() diff --git a/sleekxmpp/plugins/xep_0202/time.py b/sleekxmpp/plugins/xep_0202/time.py index ca388c5b..319a9bc5 100644 --- a/sleekxmpp/plugins/xep_0202/time.py +++ b/sleekxmpp/plugins/xep_0202/time.py @@ -40,8 +40,12 @@ class XEP_0202(BasePlugin): # custom function can be supplied which accepts
# the JID of the entity to query for the time.
self.local_time = self.config.get('local_time', None)
+
+ def default_local_time(jid):
+ return xep_0082.datetime(offset=self.tz_offset)
+
if not self.local_time:
- self.local_time = lambda x: xep_0082.datetime(offset=self.tz_offset)
+ self.local_time = default_local_time
self.xmpp.registerHandler(
Callback('Entity Time',
diff --git a/sleekxmpp/plugins/xep_0203/__init__.py b/sleekxmpp/plugins/xep_0203/__init__.py index d4d99a6c..a95ead7e 100644 --- a/sleekxmpp/plugins/xep_0203/__init__.py +++ b/sleekxmpp/plugins/xep_0203/__init__.py @@ -13,9 +13,7 @@ from sleekxmpp.plugins.xep_0203.stanza import Delay from sleekxmpp.plugins.xep_0203.delay import XEP_0203 - register_plugin(XEP_0203) - # Retain some backwards compatibility xep_0203 = XEP_0203 diff --git a/sleekxmpp/plugins/xep_0222.py b/sleekxmpp/plugins/xep_0222.py index ade78b16..724ef968 100644 --- a/sleekxmpp/plugins/xep_0222.py +++ b/sleekxmpp/plugins/xep_0222.py @@ -18,13 +18,13 @@ log = logging.getLogger(__name__) class XEP_0222(BasePlugin): """ - XEP-0222: Persistent Storage of Public Data via PubSub + XEP-0222: Persistent Storage of Public Data via PubSub """ name = 'xep_0222' description = 'XEP-0222: Persistent Storage of Private Data via PubSub' dependencies = set(['xep_0163', 'xep_0060', 'xep_0004']) - + profile = {'pubsub#persist_items': True, 'pubsub#send_last_published_item': 'never'} @@ -72,8 +72,8 @@ class XEP_0222(BasePlugin): options = self.xmpp['xep_0004'].stanza.Form() options['type'] = 'submit' options.add_field( - var='FORM_TYPE', - ftype='hidden', + var='FORM_TYPE', + ftype='hidden', value='http://jabber.org/protocol/pubsub#publish-options') for field, value in self.profile.items(): diff --git a/sleekxmpp/plugins/xep_0223.py b/sleekxmpp/plugins/xep_0223.py index 2ad257df..ab99f277 100644 --- a/sleekxmpp/plugins/xep_0223.py +++ b/sleekxmpp/plugins/xep_0223.py @@ -18,7 +18,7 @@ log = logging.getLogger(__name__) class XEP_0223(BasePlugin): """ - XEP-0223: Persistent Storage of Private Data via PubSub + XEP-0223: Persistent Storage of Private Data via PubSub """ name = 'xep_0223' @@ -72,8 +72,8 @@ class XEP_0223(BasePlugin): options = self.xmpp['xep_0004'].stanza.Form() options['type'] = 'submit' options.add_field( - var='FORM_TYPE', - ftype='hidden', + var='FORM_TYPE', + ftype='hidden', value='http://jabber.org/protocol/pubsub#publish-options') for field, value in self.profile.items(): diff --git a/sleekxmpp/plugins/xep_0231/__init__.py b/sleekxmpp/plugins/xep_0231/__init__.py index 6a70cc07..2861d67b 100644 --- a/sleekxmpp/plugins/xep_0231/__init__.py +++ b/sleekxmpp/plugins/xep_0231/__init__.py @@ -1,6 +1,6 @@ """ SleekXMPP: The Sleek XMPP Library - Copyright (C) 2012 Nathanael C. Fritz, + Copyright (C) 2012 Nathanael C. Fritz, Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> This file is part of SleekXMPP. diff --git a/sleekxmpp/plugins/xep_0231/bob.py b/sleekxmpp/plugins/xep_0231/bob.py index 011a1952..f411a8f7 100644 --- a/sleekxmpp/plugins/xep_0231/bob.py +++ b/sleekxmpp/plugins/xep_0231/bob.py @@ -1,6 +1,6 @@ """ SleekXMPP: The Sleek XMPP Library - Copyright (C) 2012 Nathanael C. Fritz, + Copyright (C) 2012 Nathanael C. Fritz, Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> This file is part of SleekXMPP. @@ -58,7 +58,6 @@ class XEP_0231(BasePlugin): self.api.register(self._set_bob, 'set_bob', default=True) self.api.register(self._del_bob, 'del_bob', default=True) - def set_bob(self, data, mtype, cid=None, max_age=None): if cid is None: cid = 'sha1+%s@bob.xmpp.org' % hashlib.sha1(data).hexdigest() @@ -73,7 +72,7 @@ class XEP_0231(BasePlugin): return cid - def get_bob(self, jid=None, cid=None, cached=True, ifrom=None, + def get_bob(self, jid=None, cid=None, cached=True, ifrom=None, block=True, timeout=None, callback=None): if cached: data = self.api['get_bob'](None, None, ifrom, args=cid) @@ -112,7 +111,7 @@ class XEP_0231(BasePlugin): iq.send() def _handle_bob(self, stanza): - self.api['set_bob'](stanza['from'], None, + self.api['set_bob'](stanza['from'], None, stanza['to'], args=stanza['bob']) self.xmpp.event('bob', stanza) diff --git a/sleekxmpp/plugins/xep_0231/stanza.py b/sleekxmpp/plugins/xep_0231/stanza.py index 13d7a5db..a51f5a03 100644 --- a/sleekxmpp/plugins/xep_0231/stanza.py +++ b/sleekxmpp/plugins/xep_0231/stanza.py @@ -1,6 +1,6 @@ """ SleekXMPP: The Sleek XMPP Library - Copyright (C) 2012 Nathanael C. Fritz, + Copyright (C) 2012 Nathanael C. Fritz, Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> This file is part of SleekXMPP. diff --git a/sleekxmpp/plugins/xep_0258/security_labels.py b/sleekxmpp/plugins/xep_0258/security_labels.py index 27be6de1..e0426f32 100644 --- a/sleekxmpp/plugins/xep_0258/security_labels.py +++ b/sleekxmpp/plugins/xep_0258/security_labels.py @@ -30,7 +30,7 @@ class XEP_0258(BasePlugin): register_stanza_plugin(Message, SecurityLabel) register_stanza_plugin(Iq, Catalog) - def get_catalog(self, jid, ifrom=None, block=True, + def get_catalog(self, jid, ifrom=None, block=True, callback=None, timeout=None): iq = self.xmpp.Iq() iq['to'] = jid diff --git a/sleekxmpp/plugins/xep_0258/stanza.py b/sleekxmpp/plugins/xep_0258/stanza.py index 6e10b28b..d844e44c 100644 --- a/sleekxmpp/plugins/xep_0258/stanza.py +++ b/sleekxmpp/plugins/xep_0258/stanza.py @@ -33,7 +33,7 @@ class Label(ElementBase): class DisplayMarking(ElementBase): name = 'displaymarking' namespace = 'urn:xmpp:sec-label:0' - plugin_attrib = 'display_marking' + plugin_attrib = 'display_marking' interfaces = set(['fgcolor', 'bgcolor', 'value']) def get_fgcolor(self): |