Fix pep8 support in src/bridge.

This commit is contained in:
Emmanuel Gil Peyrot 2013-01-18 17:55:35 +01:00
commit 60f648fdf4

View file

@ -26,27 +26,29 @@ from logging import debug, error
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 @@ class DBusBridgeFrontend(BridgeFrontend):
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 @@ class DBusBridgeFrontend(BridgeFrontend):
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 @@ class DBusBridgeFrontend(BridgeFrontend):
#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)