Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0060.py @ 594:e629371a28d3
Fix pep8 support in src/plugins.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 18 Jan 2013 17:55:35 +0100 |
parents | beaf6bec2fcd |
children | 84a6e83157c2 |
comparison
equal
deleted
inserted
replaced
593:70bae685d05c | 594:e629371a28d3 |
---|---|
28 from wokkel import disco, iwokkel, pubsub | 28 from wokkel import disco, iwokkel, pubsub |
29 | 29 |
30 from zope.interface import implements | 30 from zope.interface import implements |
31 | 31 |
32 PLUGIN_INFO = { | 32 PLUGIN_INFO = { |
33 "name": "Publish-Subscribe", | 33 "name": "Publish-Subscribe", |
34 "import_name": "XEP-0060", | 34 "import_name": "XEP-0060", |
35 "type": "XEP", | 35 "type": "XEP", |
36 "protocols": ["XEP-0060"], | 36 "protocols": ["XEP-0060"], |
37 "dependencies": [], | 37 "dependencies": [], |
38 "main": "XEP_0060", | 38 "main": "XEP_0060", |
39 "handler": "yes", | 39 "handler": "yes", |
40 "description": _("""Implementation of PubSub Protocol""") | 40 "description": _("""Implementation of PubSub Protocol""") |
41 } | 41 } |
42 | |
42 | 43 |
43 class XEP_0060(object): | 44 class XEP_0060(object): |
44 | 45 |
45 def __init__(self, host): | 46 def __init__(self, host): |
46 info(_("PubSub plugin initialization")) | 47 info(_("PubSub plugin initialization")) |
47 self.host = host | 48 self.host = host |
48 self.managedNodes=[] | 49 self.managedNodes = [] |
49 self.clients={} | 50 self.clients = {} |
50 """host.bridge.addMethod("getItems", ".plugin", in_sign='ssa{ss}s', out_sign='as', method=self.getItems, | 51 """host.bridge.addMethod("getItems", ".plugin", in_sign='ssa{ss}s', out_sign='as', method=self.getItems, |
51 async = True, | 52 async = True, |
52 doc = { 'summary':'retrieve items', | 53 doc = { 'summary':'retrieve items', |
53 'param_0':'service: pubsub service', | 54 'param_0':'service: pubsub service', |
54 'param_1':'node: node identifier', | 55 'param_1':'node: node identifier', |
76 @param profile_key: as usual :) | 77 @param profile_key: as usual :) |
77 @param action: text of action to show in case of error""" | 78 @param action: text of action to show in case of error""" |
78 profile = self.host.memory.getProfileName(profile_key) | 79 profile = self.host.memory.getProfileName(profile_key) |
79 if not profile: | 80 if not profile: |
80 err_mess = _('Trying to %(action)s with an unknown profile key [%(profile_key)s]') % { | 81 err_mess = _('Trying to %(action)s with an unknown profile key [%(profile_key)s]') % { |
81 'action':action, | 82 'action': action, |
82 'profile_key':profile_key} | 83 'profile_key': profile_key} |
83 error(err_mess) | 84 error(err_mess) |
84 raise Exception(err_mess) | 85 raise Exception(err_mess) |
85 try: | 86 try: |
86 client = self.clients[profile] | 87 client = self.clients[profile] |
87 except KeyError: | 88 except KeyError: |
89 error(err_mess) | 90 error(err_mess) |
90 raise Exception(err_mess) | 91 raise Exception(err_mess) |
91 return profile, client | 92 return profile, client |
92 | 93 |
93 def publish(self, service, nodeIdentifier, items=None, profile_key='@DEFAULT@'): | 94 def publish(self, service, nodeIdentifier, items=None, profile_key='@DEFAULT@'): |
94 profile,client = self.__getClientNProfile(profile_key, 'publish item') | 95 profile, client = self.__getClientNProfile(profile_key, 'publish item') |
95 return client.publish(service, nodeIdentifier, items, client.parent.jid) | 96 return client.publish(service, nodeIdentifier, items, client.parent.jid) |
96 | 97 |
97 def getItems(self, service, node, max_items=None, sub_id=None, profile_key='@DEFAULT@'): | 98 def getItems(self, service, node, max_items=None, sub_id=None, profile_key='@DEFAULT@'): |
98 profile,client = self.__getClientNProfile(profile_key, 'get items') | 99 profile, client = self.__getClientNProfile(profile_key, 'get items') |
99 return client.items(service, node, max_items, sub_id, client.parent.jid) | 100 return client.items(service, node, max_items, sub_id, client.parent.jid) |
100 | 101 |
101 def getOptions(self, service, nodeIdentifier, subscriber, subscriptionIdentifier=None, profile_key='@DEFAULT@'): | 102 def getOptions(self, service, nodeIdentifier, subscriber, subscriptionIdentifier=None, profile_key='@DEFAULT@'): |
102 profile,client = self.__getClientNProfile(profile_key, 'get options') | 103 profile, client = self.__getClientNProfile(profile_key, 'get options') |
103 return client.getOptions(service, nodeIdentifier, subscriber, subscriptionIdentifier) | 104 return client.getOptions(service, nodeIdentifier, subscriber, subscriptionIdentifier) |
104 | 105 |
105 def setOptions(self, service, nodeIdentifier, subscriber, options, subscriptionIdentifier=None, profile_key='@DEFAULT@'): | 106 def setOptions(self, service, nodeIdentifier, subscriber, options, subscriptionIdentifier=None, profile_key='@DEFAULT@'): |
106 profile,client = self.__getClientNProfile(profile_key, 'set options') | 107 profile, client = self.__getClientNProfile(profile_key, 'set options') |
107 return client.setOptions(service, nodeIdentifier, subscriber, options, subscriptionIdentifier) | 108 return client.setOptions(service, nodeIdentifier, subscriber, options, subscriptionIdentifier) |
108 | 109 |
109 def createNode(self, service, nodeIdentifier, options, profile_key='@DEFAULT@'): | 110 def createNode(self, service, nodeIdentifier, options, profile_key='@DEFAULT@'): |
110 profile,client = self.__getClientNProfile(profile_key, 'create node') | 111 profile, client = self.__getClientNProfile(profile_key, 'create node') |
111 return client.createNode(service, nodeIdentifier, options) | 112 return client.createNode(service, nodeIdentifier, options) |
112 | 113 |
113 def deleteNode(self, service, nodeIdentifier, profile_key='@DEFAULT@'): | 114 def deleteNode(self, service, nodeIdentifier, profile_key='@DEFAULT@'): |
114 profile,client = self.__getClientNProfile(profile_key, 'delete node') | 115 profile, client = self.__getClientNProfile(profile_key, 'delete node') |
115 return client.deleteNode(service, nodeIdentifier) | 116 return client.deleteNode(service, nodeIdentifier) |
116 | 117 |
117 def subscribe(self, service, nodeIdentifier, sub_jid = None, options=None, profile_key='@DEFAULT@'): | 118 def subscribe(self, service, nodeIdentifier, sub_jid=None, options=None, profile_key='@DEFAULT@'): |
118 profile,client = self.__getClientNProfile(profile_key, 'subscribe node') | 119 profile, client = self.__getClientNProfile(profile_key, 'subscribe node') |
119 return client.subscribe(service, nodeIdentifier, sub_jid or client.parent.jid.userhostJID(), options=options) | 120 return client.subscribe(service, nodeIdentifier, sub_jid or client.parent.jid.userhostJID(), options=options) |
120 | 121 |
121 | 122 |
122 class SatPubSubClient(pubsub.PubSubClient): | 123 class SatPubSubClient(pubsub.PubSubClient): |
123 implements(disco.IDisco) | 124 implements(disco.IDisco) |
124 | 125 |
125 def __init__(self, host, parent_plugin): | 126 def __init__(self, host, parent_plugin): |
126 self.host=host | 127 self.host = host |
127 self.parent_plugin = parent_plugin | 128 self.parent_plugin = parent_plugin |
128 pubsub.PubSubClient.__init__(self) | 129 pubsub.PubSubClient.__init__(self) |
129 | 130 |
130 def connectionInitialized(self): | 131 def connectionInitialized(self): |
131 pubsub.PubSubClient.connectionInitialized(self) | 132 pubsub.PubSubClient.connectionInitialized(self) |
150 self.host.trigger.point("PubSub Disco Info", _disco_info, self.parent.profile) | 151 self.host.trigger.point("PubSub Disco Info", _disco_info, self.parent.profile) |
151 return _disco_info | 152 return _disco_info |
152 | 153 |
153 def getDiscoItems(self, requestor, target, nodeIdentifier=''): | 154 def getDiscoItems(self, requestor, target, nodeIdentifier=''): |
154 return [] | 155 return [] |
155 |