diff sat/plugins/plugin_xep_0092.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 378188abe941
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0092.py	Wed Jun 27 07:51:29 2018 +0200
+++ b/sat/plugins/plugin_xep_0092.py	Wed Jun 27 20:14:46 2018 +0200
@@ -24,6 +24,7 @@
 from wokkel import compat
 from sat.core import exceptions
 from sat.core.log import getLogger
+
 log = getLogger(__name__)
 
 NS_VERSION = "jabber:iq:version"
@@ -37,17 +38,23 @@
     C.PI_DEPENDENCIES: [],
     C.PI_RECOMMENDATIONS: [C.TEXT_CMDS],
     C.PI_MAIN: "XEP_0092",
-    C.PI_HANDLER: "no", # version is already handler in core.xmpp module
-    C.PI_DESCRIPTION: _("""Implementation of Software Version""")
+    C.PI_HANDLER: "no",  # version is already handler in core.xmpp module
+    C.PI_DESCRIPTION: _("""Implementation of Software Version"""),
 }
 
 
 class XEP_0092(object):
-
     def __init__(self, host):
         log.info(_("Plugin XEP_0092 initialization"))
         self.host = host
-        host.bridge.addMethod("getSoftwareVersion", ".plugin", in_sign='ss', out_sign='(sss)', method=self._getVersion, async=True)
+        host.bridge.addMethod(
+            "getSoftwareVersion",
+            ".plugin",
+            in_sign="ss",
+            out_sign="(sss)",
+            method=self._getVersion,
+            async=True,
+        )
         try:
             self.host.plugins[C.TEXT_CMDS].addWhoIsCb(self._whois, 50)
         except KeyError:
@@ -56,7 +63,8 @@
     def _getVersion(self, entity_jid_s, profile_key):
         def prepareForBridge(data):
             name, version, os = data
-            return (name or '', version or '', os or '')
+            return (name or "", version or "", os or "")
+
         d = self.getVersion(jid.JID(entity_jid_s), profile_key)
         d.addCallback(prepareForBridge)
         return d
@@ -71,25 +79,29 @@
                  - os: operating system of the queried entity
         """
         client = self.host.getClient(profile_key)
+
         def getVersion(dummy):
-            iq_elt = compat.IQ(client.xmlstream, 'get')
-            iq_elt['to'] = jid_.full()
+            iq_elt = compat.IQ(client.xmlstream, "get")
+            iq_elt["to"] = jid_.full()
             iq_elt.addElement("query", NS_VERSION)
             d = iq_elt.send()
             d.addCallback(self._gotVersion)
             return d
+
         d = self.host.checkFeature(client, NS_VERSION, jid_)
         d.addCallback(getVersion)
-        reactor.callLater(TIMEOUT, d.cancel) # XXX: timeout needed because some clients don't answer the IQ
+        reactor.callLater(
+            TIMEOUT, d.cancel
+        )  # XXX: timeout needed because some clients don't answer the IQ
         return d
 
     def _gotVersion(self, iq_elt):
         try:
-            query_elt = iq_elt.elements(NS_VERSION, 'query').next()
+            query_elt = iq_elt.elements(NS_VERSION, "query").next()
         except StopIteration:
             raise exceptions.DataError
         ret = []
-        for name in ('name', 'version', 'os'):
+        for name in ("name", "version", "os"):
             try:
                 data_elt = query_elt.elements(NS_VERSION, name).next()
                 ret.append(unicode(data_elt))
@@ -98,9 +110,9 @@
 
         return tuple(ret)
 
-
     def _whois(self, client, whois_msg, mess_data, target_jid):
         """ Add software/OS information to whois """
+
         def versionCb(version_data):
             name, version, os = version_data
             if name:
@@ -109,9 +121,10 @@
                 whois_msg.append(_("Client version: %s") % version)
             if os:
                 whois_msg.append(_("Operating system: %s") % os)
+
         def versionEb(failure):
             failure.trap(exceptions.FeatureNotFound, defer.CancelledError)
-            if failure.check(failure,exceptions.FeatureNotFound):
+            if failure.check(failure, exceptions.FeatureNotFound):
                 whois_msg.append(_("Software version not available"))
             else:
                 whois_msg.append(_("Client software version request timeout"))
@@ -119,4 +132,3 @@
         d = self.getVersion(target_jid, client.profile)
         d.addCallbacks(versionCb, versionEb)
         return d
-