diff sat_frontends/bridge/pb.py @ 2624:56f94936df1e

code style reformatting using black
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 20:14:46 +0200
parents 973d4551ffae
children 779351da2c13
line wrap: on
line diff
--- a/sat_frontends/bridge/pb.py	Wed Jun 27 07:51:29 2018 +0200
+++ b/sat_frontends/bridge/pb.py	Wed Jun 27 20:14:46 2018 +0200
@@ -1,5 +1,5 @@
 #!/usr/bin/env python2
-#-*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
 
 # SAT communication bridge
 # Copyright (C) 2009-2018 Jérôme Poisson (goffi@goffi.org)
@@ -18,6 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from sat.core.log import getLogger
+
 log = getLogger(__name__)
 from sat.core import exceptions
 from twisted.spread import pb
@@ -25,11 +26,9 @@
 
 
 class SignalsHandler(pb.Referenceable):
-
     def __getattr__(self, name):
         if name.startswith("remote_"):
-            log.debug(u"calling an unregistered signal: {name}".format(
-                name = name[7:]))
+            log.debug(u"calling an unregistered signal: {name}".format(name=name[7:]))
             return lambda *args, **kwargs: None
 
         else:
@@ -43,13 +42,15 @@
         except AttributeError:
             pass
         else:
-            raise exceptions.InternalError(u"{name} signal handler has been registered twice".format(
-                name = method_name))
+            raise exceptions.InternalError(
+                u"{name} signal handler has been registered twice".format(
+                    name=method_name
+                )
+            )
         setattr(self, method_name, handler)
 
 
 class Bridge(object):
-
     def __init__(self):
         self.signals_handler = SignalsHandler()
 
@@ -81,11 +82,11 @@
         callback = errback = None
         if kwargs:
             try:
-                callback = kwargs.pop('callback')
+                callback = kwargs.pop("callback")
             except KeyError:
                 pass
             try:
-                errback = kwargs.pop('errback')
+                errback = kwargs.pop("errback")
             except KeyError:
                 pass
         elif len(args) >= 2 and callable(args[-1]) and callable(args[-2]):
@@ -132,7 +133,9 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def addContact(self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None):
+    def addContact(
+        self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None
+    ):
         d = self.root.callRemote("addContact", entity_jid, profile_key)
         if callback is not None:
             d.addCallback(lambda dummy: callback())
@@ -148,23 +151,50 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def asyncGetParamA(self, name, category, attribute="value", security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None):
-        d = self.root.callRemote("asyncGetParamA", name, category, attribute, security_limit, profile_key)
+    def asyncGetParamA(
+        self,
+        name,
+        category,
+        attribute="value",
+        security_limit=-1,
+        profile_key="@DEFAULT@",
+        callback=None,
+        errback=None,
+    ):
+        d = self.root.callRemote(
+            "asyncGetParamA", name, category, attribute, security_limit, profile_key
+        )
         if callback is not None:
             d.addCallback(callback)
         if errback is None:
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def asyncGetParamsValuesFromCategory(self, category, security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None):
-        d = self.root.callRemote("asyncGetParamsValuesFromCategory", category, security_limit, profile_key)
+    def asyncGetParamsValuesFromCategory(
+        self,
+        category,
+        security_limit=-1,
+        profile_key="@DEFAULT@",
+        callback=None,
+        errback=None,
+    ):
+        d = self.root.callRemote(
+            "asyncGetParamsValuesFromCategory", category, security_limit, profile_key
+        )
         if callback is not None:
             d.addCallback(callback)
         if errback is None:
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def connect(self, profile_key="@DEFAULT@", password='', options={}, callback=None, errback=None):
+    def connect(
+        self,
+        profile_key="@DEFAULT@",
+        password="",
+        options={},
+        callback=None,
+        errback=None,
+    ):
         d = self.root.callRemote("connect", profile_key, password, options)
         if callback is not None:
             d.addCallback(callback)
@@ -172,7 +202,9 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def delContact(self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None):
+    def delContact(
+        self, entity_jid, profile_key="@DEFAULT@", callback=None, errback=None
+    ):
         d = self.root.callRemote("delContact", entity_jid, profile_key)
         if callback is not None:
             d.addCallback(lambda dummy: callback())
@@ -180,15 +212,45 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def discoFindByFeatures(self, namespaces, identities, bare_jid=False, service=True, roster=True, own_jid=True, local_device=False, profile_key=u"@DEFAULT@", callback=None, errback=None):
-        d = self.root.callRemote("discoFindByFeatures", namespaces, identities, bare_jid, service, roster, own_jid, local_device, profile_key)
+    def discoFindByFeatures(
+        self,
+        namespaces,
+        identities,
+        bare_jid=False,
+        service=True,
+        roster=True,
+        own_jid=True,
+        local_device=False,
+        profile_key=u"@DEFAULT@",
+        callback=None,
+        errback=None,
+    ):
+        d = self.root.callRemote(
+            "discoFindByFeatures",
+            namespaces,
+            identities,
+            bare_jid,
+            service,
+            roster,
+            own_jid,
+            local_device,
+            profile_key,
+        )
         if callback is not None:
             d.addCallback(callback)
         if errback is None:
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def discoInfos(self, entity_jid, node=u'', use_cache=True, profile_key=u"@DEFAULT@", callback=None, errback=None):
+    def discoInfos(
+        self,
+        entity_jid,
+        node=u"",
+        use_cache=True,
+        profile_key=u"@DEFAULT@",
+        callback=None,
+        errback=None,
+    ):
         d = self.root.callRemote("discoInfos", entity_jid, node, use_cache, profile_key)
         if callback is not None:
             d.addCallback(callback)
@@ -196,7 +258,15 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def discoItems(self, entity_jid, node=u'', use_cache=True, profile_key=u"@DEFAULT@", callback=None, errback=None):
+    def discoItems(
+        self,
+        entity_jid,
+        node=u"",
+        use_cache=True,
+        profile_key=u"@DEFAULT@",
+        callback=None,
+        errback=None,
+    ):
         d = self.root.callRemote("discoItems", entity_jid, node, use_cache, profile_key)
         if callback is not None:
             d.addCallback(callback)
@@ -228,7 +298,9 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def getContactsFromGroup(self, group, profile_key="@DEFAULT@", callback=None, errback=None):
+    def getContactsFromGroup(
+        self, group, profile_key="@DEFAULT@", callback=None, errback=None
+    ):
         d = self.root.callRemote("getContactsFromGroup", group, profile_key)
         if callback is not None:
             d.addCallback(callback)
@@ -260,7 +332,9 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def getMainResource(self, contact_jid, profile_key="@DEFAULT@", callback=None, errback=None):
+    def getMainResource(
+        self, contact_jid, profile_key="@DEFAULT@", callback=None, errback=None
+    ):
         d = self.root.callRemote("getMainResource", contact_jid, profile_key)
         if callback is not None:
             d.addCallback(callback)
@@ -268,7 +342,15 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@", callback=None, errback=None):
+    def getParamA(
+        self,
+        name,
+        category,
+        attribute="value",
+        profile_key="@DEFAULT@",
+        callback=None,
+        errback=None,
+    ):
         d = self.root.callRemote("getParamA", name, category, attribute, profile_key)
         if callback is not None:
             d.addCallback(callback)
@@ -284,7 +366,14 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def getParamsUI(self, security_limit=-1, app='', profile_key="@DEFAULT@", callback=None, errback=None):
+    def getParamsUI(
+        self,
+        security_limit=-1,
+        app="",
+        profile_key="@DEFAULT@",
+        callback=None,
+        errback=None,
+    ):
         d = self.root.callRemote("getParamsUI", security_limit, app, profile_key)
         if callback is not None:
             d.addCallback(callback)
@@ -324,8 +413,20 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def historyGet(self, from_jid, to_jid, limit, between=True, filters='', profile="@NONE@", callback=None, errback=None):
-        d = self.root.callRemote("historyGet", from_jid, to_jid, limit, between, filters, profile)
+    def historyGet(
+        self,
+        from_jid,
+        to_jid,
+        limit,
+        between=True,
+        filters="",
+        profile="@NONE@",
+        callback=None,
+        errback=None,
+    ):
+        d = self.root.callRemote(
+            "historyGet", from_jid, to_jid, limit, between, filters, profile
+        )
         if callback is not None:
             d.addCallback(callback)
         if errback is None:
@@ -340,7 +441,9 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def launchAction(self, callback_id, data, profile_key="@DEFAULT@", callback=None, errback=None):
+    def launchAction(
+        self, callback_id, data, profile_key="@DEFAULT@", callback=None, errback=None
+    ):
         d = self.root.callRemote("launchAction", callback_id, data, profile_key)
         if callback is not None:
             d.addCallback(callback)
@@ -364,8 +467,19 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def menuLaunch(self, menu_type, path, data, security_limit, profile_key, callback=None, errback=None):
-        d = self.root.callRemote("menuLaunch", menu_type, path, data, security_limit, profile_key)
+    def menuLaunch(
+        self,
+        menu_type,
+        path,
+        data,
+        security_limit,
+        profile_key,
+        callback=None,
+        errback=None,
+    ):
+        d = self.root.callRemote(
+            "menuLaunch", menu_type, path, data, security_limit, profile_key
+        )
         if callback is not None:
             d.addCallback(callback)
         if errback is None:
@@ -380,8 +494,20 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def messageSend(self, to_jid, message, subject={}, mess_type="auto", extra={}, profile_key="@NONE@", callback=None, errback=None):
-        d = self.root.callRemote("messageSend", to_jid, message, subject, mess_type, extra, profile_key)
+    def messageSend(
+        self,
+        to_jid,
+        message,
+        subject={},
+        mess_type="auto",
+        extra={},
+        profile_key="@NONE@",
+        callback=None,
+        errback=None,
+    ):
+        d = self.root.callRemote(
+            "messageSend", to_jid, message, subject, mess_type, extra, profile_key
+        )
         if callback is not None:
             d.addCallback(lambda dummy: callback())
         if errback is None:
@@ -396,7 +522,9 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def paramsRegisterApp(self, xml, security_limit=-1, app='', callback=None, errback=None):
+    def paramsRegisterApp(
+        self, xml, security_limit=-1, app="", callback=None, errback=None
+    ):
         d = self.root.callRemote("paramsRegisterApp", xml, security_limit, app)
         if callback is not None:
             d.addCallback(lambda dummy: callback())
@@ -404,7 +532,9 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def profileCreate(self, profile, password='', component='', callback=None, errback=None):
+    def profileCreate(
+        self, profile, password="", component="", callback=None, errback=None
+    ):
         d = self.root.callRemote("profileCreate", profile, password, component)
         if callback is not None:
             d.addCallback(lambda dummy: callback())
@@ -412,7 +542,9 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def profileIsSessionStarted(self, profile_key="@DEFAULT@", callback=None, errback=None):
+    def profileIsSessionStarted(
+        self, profile_key="@DEFAULT@", callback=None, errback=None
+    ):
         d = self.root.callRemote("profileIsSessionStarted", profile_key)
         if callback is not None:
             d.addCallback(callback)
@@ -436,7 +568,9 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def profileStartSession(self, password='', profile_key="@DEFAULT@", callback=None, errback=None):
+    def profileStartSession(
+        self, password="", profile_key="@DEFAULT@", callback=None, errback=None
+    ):
         d = self.root.callRemote("profileStartSession", password, profile_key)
         if callback is not None:
             d.addCallback(callback)
@@ -444,7 +578,9 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def profilesListGet(self, clients=True, components=False, callback=None, errback=None):
+    def profilesListGet(
+        self, clients=True, components=False, callback=None, errback=None
+    ):
         d = self.root.callRemote("profilesListGet", clients, components)
         if callback is not None:
             d.addCallback(callback)
@@ -492,15 +628,34 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def setParam(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@", callback=None, errback=None):
-        d = self.root.callRemote("setParam", name, value, category, security_limit, profile_key)
+    def setParam(
+        self,
+        name,
+        value,
+        category,
+        security_limit=-1,
+        profile_key="@DEFAULT@",
+        callback=None,
+        errback=None,
+    ):
+        d = self.root.callRemote(
+            "setParam", name, value, category, security_limit, profile_key
+        )
         if callback is not None:
             d.addCallback(lambda dummy: callback())
         if errback is None:
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def setPresence(self, to_jid='', show='', statuses={}, profile_key="@DEFAULT@", callback=None, errback=None):
+    def setPresence(
+        self,
+        to_jid="",
+        show="",
+        statuses={},
+        profile_key="@DEFAULT@",
+        callback=None,
+        errback=None,
+    ):
         d = self.root.callRemote("setPresence", to_jid, show, statuses, profile_key)
         if callback is not None:
             d.addCallback(lambda dummy: callback())
@@ -508,7 +663,9 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def subscription(self, sub_type, entity, profile_key="@DEFAULT@", callback=None, errback=None):
+    def subscription(
+        self, sub_type, entity, profile_key="@DEFAULT@", callback=None, errback=None
+    ):
         d = self.root.callRemote("subscription", sub_type, entity, profile_key)
         if callback is not None:
             d.addCallback(lambda dummy: callback())
@@ -516,7 +673,15 @@
             errback = self._generic_errback
         d.addErrback(errback)
 
-    def updateContact(self, entity_jid, name, groups, profile_key="@DEFAULT@", callback=None, errback=None):
+    def updateContact(
+        self,
+        entity_jid,
+        name,
+        groups,
+        profile_key="@DEFAULT@",
+        callback=None,
+        errback=None,
+    ):
         d = self.root.callRemote("updateContact", entity_jid, name, groups, profile_key)
         if callback is not None:
             d.addCallback(lambda dummy: callback())