Mercurial > libervia-backend
comparison src/bridge/DBus.py @ 587:952322b1d490
Remove trailing whitespaces.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 18 Jan 2013 17:55:34 +0100 |
parents | ca13633d3b6b |
children | 1f160467f5de |
comparison
equal
deleted
inserted
replaced
586:6a718ede8be1 | 587:952322b1d490 |
---|---|
92 if isinstance(result, Deferred): | 92 if isinstance(result, Deferred): |
93 error("Synchronous method [%s] return a Deferred." % name) | 93 error("Synchronous method [%s] return a Deferred." % name) |
94 raise DeferredNotAsync | 94 raise DeferredNotAsync |
95 return result | 95 return result |
96 | 96 |
97 ### signals ### | 97 ### signals ### |
98 | 98 |
99 @dbus.service.signal(const_INT_PREFIX+const_PLUGIN_SUFFIX, | 99 @dbus.service.signal(const_INT_PREFIX+const_PLUGIN_SUFFIX, |
100 signature='') | 100 signature='') |
101 def dummySignal(self): | 101 def dummySignal(self): |
102 #FIXME: workaround for addSignal (doesn't work if one method doensn't | 102 #FIXME: workaround for addSignal (doesn't work if one method doensn't |
173 signature='sss') | 173 signature='sss') |
174 def subscribe(self, sub_type, entity_jid, profile): | 174 def subscribe(self, sub_type, entity_jid, profile): |
175 pass | 175 pass |
176 | 176 |
177 | 177 |
178 ### methods ### | 178 ### methods ### |
179 | 179 |
180 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, | 180 @dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX, |
181 in_signature='ss', out_signature='', | 181 in_signature='ss', out_signature='', |
182 async_callbacks=None) | 182 async_callbacks=None) |
183 def addContact(self, entity_jid, profile_key="@DEFAULT@"): | 183 def addContact(self, entity_jid, profile_key="@DEFAULT@"): |
184 return self._callback("addContact", unicode(entity_jid), unicode(profile_key)) | 184 return self._callback("addContact", unicode(entity_jid), unicode(profile_key)) |
409 in_signature='ssass', out_signature='', | 409 in_signature='ssass', out_signature='', |
410 async_callbacks=None) | 410 async_callbacks=None) |
411 def updateContact(self, entity_jid, name, groups, profile_key="@DEFAULT@"): | 411 def updateContact(self, entity_jid, name, groups, profile_key="@DEFAULT@"): |
412 return self._callback("updateContact", unicode(entity_jid), unicode(name), groups, unicode(profile_key)) | 412 return self._callback("updateContact", unicode(entity_jid), unicode(name), groups, unicode(profile_key)) |
413 | 413 |
414 | 414 |
415 def __attributes(self, in_sign): | 415 def __attributes(self, in_sign): |
416 """Return arguments to user given a in_sign | 416 """Return arguments to user given a in_sign |
417 @param in_sign: in_sign in the short form (using s,a,i,b etc) | 417 @param in_sign: in_sign in the short form (using s,a,i,b etc) |
418 @return: list of arguments that correspond to a in_sign (e.g.: "sss" return "arg1, arg2, arg3")""" | 418 @return: list of arguments that correspond to a in_sign (e.g.: "sss" return "arg1, arg2, arg3")""" |
419 i=0 | 419 i=0 |
420 idx=0 | 420 idx=0 |
421 attr=[] | 421 attr=[] |
422 while i<len(in_sign): | 422 while i<len(in_sign): |
423 if in_sign[i] not in ['b','y','n','i','x','q','u','t','d','s','a']: | 423 if in_sign[i] not in ['b','y','n','i','x','q','u','t','d','s','a']: |
452 """Dynamically add a method to Dbus Bridge""" | 452 """Dynamically add a method to Dbus Bridge""" |
453 inspect_args = inspect.getargspec(method) | 453 inspect_args = inspect.getargspec(method) |
454 | 454 |
455 _arguments = inspect_args.args | 455 _arguments = inspect_args.args |
456 _defaults = list(inspect_args.defaults or []) | 456 _defaults = list(inspect_args.defaults or []) |
457 | 457 |
458 if inspect.ismethod(method): | 458 if inspect.ismethod(method): |
459 #if we have a method, we don't want the first argument (usually 'self') | 459 #if we have a method, we don't want the first argument (usually 'self') |
460 del(_arguments[0]) | 460 del(_arguments[0]) |
461 | 461 |
462 #first arguments are for the _callback method | 462 #first arguments are for the _callback method |
463 arguments_callback = ', '.join([repr(name)] + ((_arguments + ['callback=callback','errback=errback']) if async else _arguments)) | 463 arguments_callback = ', '.join([repr(name)] + ((_arguments + ['callback=callback','errback=errback']) if async else _arguments)) |
464 | 464 |
465 if async: | 465 if async: |
466 _arguments.extend(['callback','errback']) | 466 _arguments.extend(['callback','errback']) |
467 _defaults.extend([None, None]) | 467 _defaults.extend([None, None]) |
468 | 468 |
469 | 469 |
470 #now we create a second list with default values | 470 #now we create a second list with default values |
471 for i in range(1, len(_defaults)+1): | 471 for i in range(1, len(_defaults)+1): |
472 _arguments[-i] = "%s = %s" % (_arguments[-i], repr(_defaults[-i])) | 472 _arguments[-i] = "%s = %s" % (_arguments[-i], repr(_defaults[-i])) |
473 | 473 |
474 arguments_defaults = ', '.join(_arguments) | 474 arguments_defaults = ', '.join(_arguments) |
482 const_INT_PREFIX+int_suffix, in_signature=in_sign, out_signature=out_sign, | 482 const_INT_PREFIX+int_suffix, in_signature=in_sign, out_signature=out_sign, |
483 async_callbacks=async_callbacks)(method)) | 483 async_callbacks=async_callbacks)(method)) |
484 function = getattr(self, name) | 484 function = getattr(self, name) |
485 func_table = self._dbus_class_table[self.__class__.__module__ + '.' + self.__class__.__name__][function._dbus_interface] | 485 func_table = self._dbus_class_table[self.__class__.__module__ + '.' + self.__class__.__name__][function._dbus_interface] |
486 func_table[function.__name__] = function #Needed for introspection | 486 func_table[function.__name__] = function #Needed for introspection |
487 | 487 |
488 def addSignal(self, name, int_suffix, signature, doc={}): | 488 def addSignal(self, name, int_suffix, signature, doc={}): |
489 """Dynamically add a signal to Dbus Bridge""" | 489 """Dynamically add a signal to Dbus Bridge""" |
490 attributes = ', '.join(self.__attributes(signature)) | 490 attributes = ', '.join(self.__attributes(signature)) |
491 #TODO: use doc parameter to name attributes | 491 #TODO: use doc parameter to name attributes |
492 | 492 |