comparison src/bridge/bridge_constructor/dbus_core_template.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
104 # further investigations 104 # further investigations
105 pass 105 pass
106 106
107 ##SIGNALS_PART## 107 ##SIGNALS_PART##
108 108
109 ### methods ### 109 ### methods ###
110 110
111 ##METHODS_PART## 111 ##METHODS_PART##
112 112
113 def __attributes(self, in_sign): 113 def __attributes(self, in_sign):
114 """Return arguments to user given a in_sign 114 """Return arguments to user given a in_sign
115 @param in_sign: in_sign in the short form (using s,a,i,b etc) 115 @param in_sign: in_sign in the short form (using s,a,i,b etc)
116 @return: list of arguments that correspond to a in_sign (e.g.: "sss" return "arg1, arg2, arg3")""" 116 @return: list of arguments that correspond to a in_sign (e.g.: "sss" return "arg1, arg2, arg3")"""
117 i=0 117 i=0
118 idx=0 118 idx=0
119 attr=[] 119 attr=[]
120 while i<len(in_sign): 120 while i<len(in_sign):
121 if in_sign[i] not in ['b','y','n','i','x','q','u','t','d','s','a']: 121 if in_sign[i] not in ['b','y','n','i','x','q','u','t','d','s','a']:
150 """Dynamically add a method to Dbus Bridge""" 150 """Dynamically add a method to Dbus Bridge"""
151 inspect_args = inspect.getargspec(method) 151 inspect_args = inspect.getargspec(method)
152 152
153 _arguments = inspect_args.args 153 _arguments = inspect_args.args
154 _defaults = list(inspect_args.defaults or []) 154 _defaults = list(inspect_args.defaults or [])
155 155
156 if inspect.ismethod(method): 156 if inspect.ismethod(method):
157 #if we have a method, we don't want the first argument (usually 'self') 157 #if we have a method, we don't want the first argument (usually 'self')
158 del(_arguments[0]) 158 del(_arguments[0])
159 159
160 #first arguments are for the _callback method 160 #first arguments are for the _callback method
161 arguments_callback = ', '.join([repr(name)] + ((_arguments + ['callback=callback','errback=errback']) if async else _arguments)) 161 arguments_callback = ', '.join([repr(name)] + ((_arguments + ['callback=callback','errback=errback']) if async else _arguments))
162 162
163 if async: 163 if async:
164 _arguments.extend(['callback','errback']) 164 _arguments.extend(['callback','errback'])
165 _defaults.extend([None, None]) 165 _defaults.extend([None, None])
166 166
167 167
168 #now we create a second list with default values 168 #now we create a second list with default values
169 for i in range(1, len(_defaults)+1): 169 for i in range(1, len(_defaults)+1):
170 _arguments[-i] = "%s = %s" % (_arguments[-i], repr(_defaults[-i])) 170 _arguments[-i] = "%s = %s" % (_arguments[-i], repr(_defaults[-i]))
171 171
172 arguments_defaults = ', '.join(_arguments) 172 arguments_defaults = ', '.join(_arguments)
180 const_INT_PREFIX+int_suffix, in_signature=in_sign, out_signature=out_sign, 180 const_INT_PREFIX+int_suffix, in_signature=in_sign, out_signature=out_sign,
181 async_callbacks=async_callbacks)(method)) 181 async_callbacks=async_callbacks)(method))
182 function = getattr(self, name) 182 function = getattr(self, name)
183 func_table = self._dbus_class_table[self.__class__.__module__ + '.' + self.__class__.__name__][function._dbus_interface] 183 func_table = self._dbus_class_table[self.__class__.__module__ + '.' + self.__class__.__name__][function._dbus_interface]
184 func_table[function.__name__] = function #Needed for introspection 184 func_table[function.__name__] = function #Needed for introspection
185 185
186 def addSignal(self, name, int_suffix, signature, doc={}): 186 def addSignal(self, name, int_suffix, signature, doc={}):
187 """Dynamically add a signal to Dbus Bridge""" 187 """Dynamically add a signal to Dbus Bridge"""
188 attributes = ', '.join(self.__attributes(signature)) 188 attributes = ', '.join(self.__attributes(signature))
189 #TODO: use doc parameter to name attributes 189 #TODO: use doc parameter to name attributes
190 190