diff sat/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 787b15d16347
children 779351da2c13
line wrap: on
line diff
--- a/sat/bridge/pb.py	Wed Jun 27 07:51:29 2018 +0200
+++ b/sat/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: a jabber client
 # Copyright (C) 2009-2018 Jérôme Poisson (goffi@goffi.org)
@@ -19,6 +19,7 @@
 
 
 from sat.core.log import getLogger
+
 log = getLogger(__name__)
 from twisted.spread import jelly, pb
 from twisted.internet import reactor
@@ -28,17 +29,18 @@
 # we monkey patch jelly to handle namedtuple
 ori_jelly = jelly._Jellier.jelly
 
+
 def fixed_jelly(self, obj):
     """this method fix handling of namedtuple"""
     if isinstance(obj, tuple) and not obj is tuple:
         obj = tuple(obj)
     return ori_jelly(self, obj)
 
+
 jelly._Jellier.jelly = fixed_jelly
 
 
 class PBRoot(pb.Root):
-
     def __init__(self):
         self.signals_handlers = []
 
@@ -47,10 +49,11 @@
         log.info(u"registered signal handler")
 
     def sendSignalEb(self, failure, signal_name):
-        log.error(u"Error while sending signal {name}: {msg}".format(
-            name = signal_name,
-            msg = failure,
-            ))
+        log.error(
+            u"Error while sending signal {name}: {msg}".format(
+                name=signal_name, msg=failure
+            )
+        )
 
     def sendSignal(self, name, args, kwargs):
         to_remove = []
@@ -66,11 +69,11 @@
                 log.debug(u"Removing signal handler for dead frontend")
                 self.signals_handlers.remove(handler)
 
+
 ##METHODS_PART##
 
 
 class Bridge(object):
-
     def __init__(self):
         log.info("Init Perspective Broker...")
         self.root = PBRoot()
@@ -85,18 +88,20 @@
 
     def register_method(self, name, callback):
         log.debug("registering PB bridge method [%s]" % name)
-        setattr(self.root, "remote_"+name, callback)
-        # self.root.register_method(name, callback)
+        setattr(self.root, "remote_" + name, callback)
+        #  self.root.register_method(name, callback)
 
     def addMethod(self, name, int_suffix, in_sign, out_sign, method, async=False, doc={}):
         """Dynamically add a method to PB Bridge"""
-        #FIXME: doc parameter is kept only temporary, the time to remove it from calls
+        # FIXME: doc parameter is kept only temporary, the time to remove it from calls
         log.debug("Adding method {name} to PB bridge".format(name=name))
         self.register_method(name, method)
 
     def addSignal(self, name, int_suffix, signature, doc={}):
         log.debug("Adding signal {name} to PB bridge".format(name=name))
-        setattr(self, name, lambda *args, **kwargs: self.sendSignal(name, *args, **kwargs))
+        setattr(
+            self, name, lambda *args, **kwargs: self.sendSignal(name, *args, **kwargs)
+        )
 
     def actionNew(self, action_data, id, security_limit, profile):
         self.sendSignal("actionNew", action_data, id, security_limit, profile)
@@ -113,8 +118,30 @@
     def entityDataUpdated(self, jid, name, value, profile):
         self.sendSignal("entityDataUpdated", jid, name, value, profile)
 
-    def messageNew(self, uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra, profile):
-        self.sendSignal("messageNew", uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra, profile)
+    def messageNew(
+        self,
+        uid,
+        timestamp,
+        from_jid,
+        to_jid,
+        message,
+        subject,
+        mess_type,
+        extra,
+        profile,
+    ):
+        self.sendSignal(
+            "messageNew",
+            uid,
+            timestamp,
+            from_jid,
+            to_jid,
+            message,
+            subject,
+            mess_type,
+            extra,
+            profile,
+        )
 
     def newContact(self, contact_jid, attributes, groups, profile):
         self.sendSignal("newContact", contact_jid, attributes, groups, profile)