code style reformatting using black

This commit is contained in:
Goffi 2018-06-27 20:14:46 +02:00
commit 744cb0c503

View file

@ -21,9 +21,11 @@
from sat.core.constants import Const as C
from sat.core.i18n import _, D_
from sat.core.log import getLogger
log = getLogger(__name__)
from wokkel import disco, iwokkel
try:
from twisted.words.protocols.xmlstream import XMPPHandler
except ImportError:
@ -41,7 +43,7 @@ PLUGIN_INFO = {
C.PI_PROTOCOLS: [u"XEP-0297"],
C.PI_MAIN: "XEP_0297",
C.PI_HANDLER: u"yes",
C.PI_DESCRIPTION: D_(u"""Implementation of Stanza Forwarding""")
C.PI_DESCRIPTION: D_(u"""Implementation of Stanza Forwarding"""),
}
@ -70,7 +72,7 @@ class XEP_0297(object):
if isinstance(child, domish.Element) and not child.uri:
XEP_0297.updateUri(child, uri)
def forward(self, stanza, to_jid, stamp, body='', profile_key=C.PROF_KEY_NONE):
def forward(self, stanza, to_jid, stamp, body="", profile_key=C.PROF_KEY_NONE):
"""Forward a message to the given JID.
@param stanza (domish.Element): original stanza to be forwarded.
@ -82,27 +84,29 @@ class XEP_0297(object):
"""
# FIXME: this method is not used and doesn't use mess_data which should be used for client.sendMessageData
# should it be deprecated? A method constructing the element without sending it seems more natural
log.warning(u"THIS METHOD IS DEPRECATED") # FIXME: we use this warning until we check the method
msg = domish.Element((None, 'message'))
msg['to'] = to_jid.full()
msg['type'] = stanza['type']
log.warning(
u"THIS METHOD IS DEPRECATED"
) #  FIXME: we use this warning until we check the method
msg = domish.Element((None, "message"))
msg["to"] = to_jid.full()
msg["type"] = stanza["type"]
body_elt = domish.Element((None, 'body'))
body_elt = domish.Element((None, "body"))
if body:
body_elt.addContent(body)
forwarded_elt = domish.Element((NS_SF, 'forwarded'))
delay_elt = self.host.plugins['XEP-0203'].delay(stamp)
forwarded_elt = domish.Element((NS_SF, "forwarded"))
delay_elt = self.host.plugins["XEP-0203"].delay(stamp)
forwarded_elt.addChild(delay_elt)
if not stanza.uri: # None or ''
XEP_0297.updateUri(stanza, 'jabber:client')
XEP_0297.updateUri(stanza, "jabber:client")
forwarded_elt.addChild(stanza)
msg.addChild(body_elt)
msg.addChild(forwarded_elt)
client = self.host.getClient(profile_key)
return client.sendMessageData({u'xml': msg})
return client.sendMessageData({u"xml": msg})
class XEP_0297_handler(XMPPHandler):
@ -113,8 +117,8 @@ class XEP_0297_handler(XMPPHandler):
self.host = plugin_parent.host
self.profile = profile
def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
def getDiscoInfo(self, requestor, target, nodeIdentifier=""):
return [disco.DiscoFeature(NS_SF)]
def getDiscoItems(self, requestor, target, nodeIdentifier=''):
def getDiscoItems(self, requestor, target, nodeIdentifier=""):
return []