diff frontends/src/bridge/DBus.py @ 595:1f160467f5de

Fix pep8 support in src/bridge.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 18 Jan 2013 17:55:35 +0100
parents 952322b1d490
children 84a6e83157c2
line wrap: on
line diff
--- a/frontends/src/bridge/DBus.py	Fri Jan 18 17:55:35 2013 +0100
+++ b/frontends/src/bridge/DBus.py	Fri Jan 18 17:55:35 2013 +0100
@@ -26,27 +26,29 @@
 from dbus.mainloop.glib import DBusGMainLoop
 DBusGMainLoop(set_as_default=True)
 
-const_INT_PREFIX = "org.goffi.SAT"  #Interface prefix
-const_ERROR_PREFIX = const_INT_PREFIX+".error"
+const_INT_PREFIX = "org.goffi.SAT"  # Interface prefix
+const_ERROR_PREFIX = const_INT_PREFIX + ".error"
 const_OBJ_PATH = '/org/goffi/SAT/bridge'
 const_CORE_SUFFIX = ".core"
 const_PLUGIN_SUFFIX = ".plugin"
 
+
 class BridgeExceptionNoService(Exception):
     pass
 
+
 class DBusBridgeFrontend(BridgeFrontend):
     def __init__(self):
         try:
             self.sessions_bus = dbus.SessionBus()
             self.db_object = self.sessions_bus.get_object(const_INT_PREFIX,
-                                const_OBJ_PATH)
+                                                          const_OBJ_PATH)
             self.db_core_iface = dbus.Interface(self.db_object,
-                                dbus_interface=const_INT_PREFIX + const_CORE_SUFFIX)
+                                                dbus_interface=const_INT_PREFIX + const_CORE_SUFFIX)
             self.db_plugin_iface = dbus.Interface(self.db_object,
-                                dbus_interface=const_INT_PREFIX + const_PLUGIN_SUFFIX)
-        except dbus.exceptions.DBusException,e:
-            if e._dbus_error_name=='org.freedesktop.DBus.Error.ServiceUnknown':
+                                                  dbus_interface=const_INT_PREFIX + const_PLUGIN_SUFFIX)
+        except dbus.exceptions.DBusException, e:
+            if e._dbus_error_name == 'org.freedesktop.DBus.Error.ServiceUnknown':
                 raise BridgeExceptionNoService
             else:
                 raise e
@@ -79,7 +81,7 @@
                         async = True
                         _callback = kwargs.pop('callback')
                         _errback = kwargs.pop('errback')
-                elif len(args)>=2 and callable(args[-1]) and callable(args[-2]):
+                elif len(args) >= 2 and callable(args[-1]) and callable(args[-2]):
                     async = True
                     args = list(args)
                     _errback = args.pop()
@@ -89,12 +91,11 @@
 
                 if async:
                     kwargs['reply_handler'] = _callback
-                    kwargs['error_handler'] = lambda err:_errback(err._dbus_error_name[len(const_ERROR_PREFIX)+1:])
+                    kwargs['error_handler'] = lambda err: _errback(err._dbus_error_name[len(const_ERROR_PREFIX) + 1:])
 
                 return method(*args, **kwargs)
 
             return getPluginMethod
-
     def addContact(self, entity_jid, profile_key="@DEFAULT@"):
         return self.db_core_iface.addContact(entity_jid, profile_key)
 
@@ -216,11 +217,11 @@
 #methods from plugins
 
     def joinMUC(self, room_jid, nick, options, profile_key):
-        if options == None:
-            options = [('', '')] #XXX: we have to do this awful hack because python dbus need to guess the signature
+        if options is None:
+            options = [('', '')]  # XXX: we have to do this awful hack because python dbus need to guess the signature
         return self.db_plugin_iface.joinMUC(room_jid, nick, options, profile_key)
 
     def gatewayRegister(self, action, target, data, profile_key):
-        if data == None:
-            data = [('', '')] #XXX: we have to do this awful hack because python dbus need to guess the signature
+        if data is None:
+            data = [('', '')]  # XXX: we have to do this awful hack because python dbus need to guess the signature
         return self.db_plugin_iface.gatewayRegister(action, target, data, profile_key)
\ No newline at end of file