Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0203.py @ 2624:56f94936df1e
code style reformatting using black
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 27 Jun 2018 20:14:46 +0200 |
parents | 26edcf3a30eb |
children | 003b8b4b56a7 |
comparison
equal
deleted
inserted
replaced
2623:49533de4540b | 2624:56f94936df1e |
---|---|
19 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | 20 |
21 from sat.core.i18n import _ | 21 from sat.core.i18n import _ |
22 from sat.core.constants import Const as C | 22 from sat.core.constants import Const as C |
23 from sat.core.log import getLogger | 23 from sat.core.log import getLogger |
24 | |
24 log = getLogger(__name__) | 25 log = getLogger(__name__) |
25 | 26 |
26 from wokkel import disco, iwokkel, delay | 27 from wokkel import disco, iwokkel, delay |
28 | |
27 try: | 29 try: |
28 from twisted.words.protocols.xmlstream import XMPPHandler | 30 from twisted.words.protocols.xmlstream import XMPPHandler |
29 except ImportError: | 31 except ImportError: |
30 from wokkel.subprotocols import XMPPHandler | 32 from wokkel.subprotocols import XMPPHandler |
31 from zope.interface import implements | 33 from zope.interface import implements |
32 | 34 |
33 | 35 |
34 NS_DD = 'urn:xmpp:delay' | 36 NS_DD = "urn:xmpp:delay" |
35 | 37 |
36 PLUGIN_INFO = { | 38 PLUGIN_INFO = { |
37 C.PI_NAME: "Delayed Delivery", | 39 C.PI_NAME: "Delayed Delivery", |
38 C.PI_IMPORT_NAME: "XEP-0203", | 40 C.PI_IMPORT_NAME: "XEP-0203", |
39 C.PI_TYPE: "XEP", | 41 C.PI_TYPE: "XEP", |
40 C.PI_PROTOCOLS: ["XEP-0203"], | 42 C.PI_PROTOCOLS: ["XEP-0203"], |
41 C.PI_MAIN: "XEP_0203", | 43 C.PI_MAIN: "XEP_0203", |
42 C.PI_HANDLER: "yes", | 44 C.PI_HANDLER: "yes", |
43 C.PI_DESCRIPTION: _("""Implementation of Delayed Delivery""") | 45 C.PI_DESCRIPTION: _("""Implementation of Delayed Delivery"""), |
44 } | 46 } |
45 | 47 |
46 | 48 |
47 class XEP_0203(object): | 49 class XEP_0203(object): |
48 | |
49 def __init__(self, host): | 50 def __init__(self, host): |
50 log.info(_("Delayed Delivery plugin initialization")) | 51 log.info(_("Delayed Delivery plugin initialization")) |
51 self.host = host | 52 self.host = host |
52 | 53 |
53 def getHandler(self, client): | 54 def getHandler(self, client): |
54 return XEP_0203_handler(self, client.profile) | 55 return XEP_0203_handler(self, client.profile) |
55 | 56 |
56 def delay(self, stamp, sender=None, desc='', parent=None): | 57 def delay(self, stamp, sender=None, desc="", parent=None): |
57 """Build a delay element, eventually append it to the given parent element. | 58 """Build a delay element, eventually append it to the given parent element. |
58 | 59 |
59 @param stamp (datetime): offset-aware timestamp of the original sending. | 60 @param stamp (datetime): offset-aware timestamp of the original sending. |
60 @param sender (JID): entity that originally sent or delayed the message. | 61 @param sender (JID): entity that originally sent or delayed the message. |
61 @param desc (unicode): optional natural language description. | 62 @param desc (unicode): optional natural language description. |
76 def __init__(self, plugin_parent, profile): | 77 def __init__(self, plugin_parent, profile): |
77 self.plugin_parent = plugin_parent | 78 self.plugin_parent = plugin_parent |
78 self.host = plugin_parent.host | 79 self.host = plugin_parent.host |
79 self.profile = profile | 80 self.profile = profile |
80 | 81 |
81 def getDiscoInfo(self, requestor, target, nodeIdentifier=''): | 82 def getDiscoInfo(self, requestor, target, nodeIdentifier=""): |
82 return [disco.DiscoFeature(NS_DD)] | 83 return [disco.DiscoFeature(NS_DD)] |
83 | 84 |
84 def getDiscoItems(self, requestor, target, nodeIdentifier=''): | 85 def getDiscoItems(self, requestor, target, nodeIdentifier=""): |
85 return [] | 86 return [] |