Remove trailing whitespaces.
This commit is contained in:
parent
310e2cc347
commit
27b3592e16
4 changed files with 899 additions and 899 deletions
|
|
@ -53,11 +53,11 @@ from xml.dom import minidom
|
|||
|
||||
|
||||
class ParseError(Exception):
|
||||
#Used when the signature parsing is going wrong (invalid signature ?)
|
||||
#Used when the signature parsing is going wrong (invalid signature ?)
|
||||
pass
|
||||
|
||||
class Constructor:
|
||||
|
||||
|
||||
def __init__(self, bridge_template, options):
|
||||
self.bridge_template = bridge_template
|
||||
self.options = options
|
||||
|
|
@ -74,14 +74,14 @@ class Constructor:
|
|||
value = None
|
||||
function[option] = value
|
||||
return function
|
||||
|
||||
|
||||
def getDefault(self, name):
|
||||
"""Return default values of a function in a dict
|
||||
@param name: Name of the function to get
|
||||
@return: dict, each key is the integer param number (no key if no default value)"""
|
||||
default_dict={}
|
||||
def_re = re.compile(r"param_(\d+)_default")
|
||||
|
||||
|
||||
for option in self.bridge_template.options(name):
|
||||
match = def_re.match(option)
|
||||
if match:
|
||||
|
|
@ -90,7 +90,7 @@ class Constructor:
|
|||
except ValueError:
|
||||
raise ParseError("Invalid value [%s] for parameter number" % match.group(1))
|
||||
default_dict[idx] = self.bridge_template.get(name, option)
|
||||
|
||||
|
||||
return default_dict
|
||||
|
||||
def getFlags(self, name):
|
||||
|
|
@ -102,7 +102,7 @@ class Constructor:
|
|||
if option in FLAGS:
|
||||
flags.append(option)
|
||||
return flags
|
||||
|
||||
|
||||
def getArgumentsDoc(self, name):
|
||||
"""Return documentation of arguments
|
||||
@param name: Name of the function to get
|
||||
|
|
@ -175,10 +175,10 @@ class Constructor:
|
|||
@param name: dictionary of arguments name like given by getArguments
|
||||
@param default: dictionary of default values, like given by getDefault
|
||||
@param unicode_protect: activate unicode protection on strings (return strings as unicode(str))
|
||||
@return: list of arguments that correspond to a signature (e.g.: "sss" return "arg1, arg2, arg3")"""
|
||||
@return: list of arguments that correspond to a signature (e.g.: "sss" return "arg1, arg2, arg3")"""
|
||||
idx=0
|
||||
attr_string=[]
|
||||
|
||||
|
||||
for arg in self.argumentsParser(signature):
|
||||
attr_string.append(("unicode(%(name)s)%(default)s" if (unicode_protect and arg=='s') else "%(name)s%(default)s") % {
|
||||
'name':name[idx][0] if (name and name.has_key(idx)) else "arg_%i" % idx,
|
||||
|
|
@ -186,7 +186,7 @@ class Constructor:
|
|||
}) #give arg_1, arg2, etc or name1, name2=default, etc. \
|
||||
#give unicode(arg_1), unicode(arg_2), etc. if unicode_protect is set and arg is a string
|
||||
idx+=1
|
||||
|
||||
|
||||
return ", ".join(attr_string)
|
||||
|
||||
def generateCoreSide(self):
|
||||
|
|
@ -209,7 +209,7 @@ class Constructor:
|
|||
os.mkdir(DEST_DIR)
|
||||
full_path=os.path.join(DEST_DIR,filename)
|
||||
if os.path.exists(full_path) and not self.options.force:
|
||||
print ("The destination file [%s] already exists ! Use --force to overwrite it" % full_path)
|
||||
print ("The destination file [%s] already exists ! Use --force to overwrite it" % full_path)
|
||||
try:
|
||||
with open(full_path,'w') as dest_file:
|
||||
dest_file.write('\n'.join(file_buf))
|
||||
|
|
@ -223,8 +223,8 @@ class MediawikiConstructor(Constructor):
|
|||
|
||||
def __init__(self, bridge_template, options):
|
||||
Constructor.__init__(self, bridge_template, options)
|
||||
self.core_template="mediawiki_template.tpl"
|
||||
self.core_dest="mediawiki.wiki"
|
||||
self.core_template="mediawiki_template.tpl"
|
||||
self.core_dest="mediawiki.wiki"
|
||||
|
||||
def _addTextDecorations(self, text):
|
||||
"""Add text decorations like coloration or shortcuts"""
|
||||
|
|
@ -259,7 +259,7 @@ class MediawikiConstructor(Constructor):
|
|||
if arg_default.has_key(i):
|
||||
wiki.append(":''DEFAULT: %s''" % arg_default[i])
|
||||
return "\n".join(wiki)
|
||||
|
||||
|
||||
def _wikiReturn(self, name):
|
||||
"""Format return doc with the wiki syntax
|
||||
@param name: name of the function
|
||||
|
|
@ -317,7 +317,7 @@ class MediawikiConstructor(Constructor):
|
|||
%(async)s
|
||||
{| class="wikitable" style="text-align:left; width:80%%;"
|
||||
! scope=row | category
|
||||
| %(category)s
|
||||
| %(category)s
|
||||
|-
|
||||
%(signature)s
|
||||
! scope=row | parameters
|
||||
|
|
@ -325,7 +325,7 @@ class MediawikiConstructor(Constructor):
|
|||
%(parameters)s%(return)s
|
||||
|}
|
||||
""" % completion)
|
||||
|
||||
|
||||
#at this point, signals_part, and methods_part should be filled,
|
||||
#we just have to place them in the right part of the template
|
||||
core_bridge = []
|
||||
|
|
@ -342,7 +342,7 @@ class MediawikiConstructor(Constructor):
|
|||
core_bridge.append(line.replace('\n',''))
|
||||
except IOError:
|
||||
print ("Can't open template file [%s]" % self.core_template)
|
||||
sys.exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
#now we write to final file
|
||||
self.finalWrite(self.core_dest, core_bridge)
|
||||
|
|
@ -351,9 +351,9 @@ class DbusConstructor(Constructor):
|
|||
|
||||
def __init__(self, bridge_template, options):
|
||||
Constructor.__init__(self, bridge_template, options)
|
||||
self.core_template="dbus_core_template.py"
|
||||
self.frontend_template="dbus_frontend_template.py"
|
||||
self.frontend_dest = self.core_dest="DBus.py"
|
||||
self.core_template="dbus_core_template.py"
|
||||
self.frontend_template="dbus_frontend_template.py"
|
||||
self.frontend_dest = self.core_dest="DBus.py"
|
||||
|
||||
def generateCoreSide(self):
|
||||
signals_part = []
|
||||
|
|
@ -371,7 +371,7 @@ class DbusConstructor(Constructor):
|
|||
'sig_in':function['sig_in'] or '',
|
||||
'sig_out':function['sig_out'] or '',
|
||||
'category':'PLUGIN' if function['category'] == 'plugin' else 'CORE',
|
||||
'name':section,
|
||||
'name':section,
|
||||
'args':self.getArguments(function['sig_in'], name=arg_doc, default=default )
|
||||
}
|
||||
|
||||
|
|
@ -427,7 +427,7 @@ class DbusConstructor(Constructor):
|
|||
core_bridge.append(line.replace('\n',''))
|
||||
except IOError:
|
||||
print ("Can't open template file [%s]" % self.core_template)
|
||||
sys.exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
#now we write to final file
|
||||
self.finalWrite(self.core_dest, core_bridge)
|
||||
|
|
@ -446,7 +446,7 @@ class DbusConstructor(Constructor):
|
|||
'sig_in':function['sig_in'] or '',
|
||||
'sig_out':function['sig_out'] or '',
|
||||
'category':'plugin' if function['category'] == 'plugin' else 'core',
|
||||
'name':section,
|
||||
'name':section,
|
||||
'args':self.getArguments(function['sig_in'], name=arg_doc, default=default)
|
||||
}
|
||||
|
||||
|
|
@ -483,7 +483,7 @@ class DbusConstructor(Constructor):
|
|||
frontend_bridge.append(line.replace('\n',''))
|
||||
except IOError:
|
||||
print ("Can't open template file [%s]" % self.frontend_template)
|
||||
sys.exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
#now we write to final file
|
||||
self.finalWrite(self.frontend_dest, frontend_bridge)
|
||||
|
|
@ -493,8 +493,8 @@ class DbusXmlConstructor(Constructor):
|
|||
|
||||
def __init__(self, bridge_template, options):
|
||||
Constructor.__init__(self, bridge_template, options)
|
||||
|
||||
self.template="dbus_xml_template.xml"
|
||||
|
||||
self.template="dbus_xml_template.xml"
|
||||
self.core_dest="org.goffi.sat.xml"
|
||||
self.default_annotation = { 'a{ss}': 'StringDict',
|
||||
'a(sa{ss}as)': 'QList<Contact>',
|
||||
|
|
@ -540,7 +540,7 @@ class DbusXmlConstructor(Constructor):
|
|||
annot_elt.setAttribute('value', self.default_annotation[arg])
|
||||
new_elt.appendChild(annot_elt)
|
||||
idx+=1
|
||||
|
||||
|
||||
if function['sig_out']:
|
||||
arg_elt = doc.createElement('arg')
|
||||
arg_elt.setAttribute('type', function['sig_out'])
|
||||
|
|
@ -575,7 +575,7 @@ class ConstructorFactory:
|
|||
class BridgeConstructor:
|
||||
def __init__(self):
|
||||
self.options = None
|
||||
|
||||
|
||||
def check_options(self):
|
||||
"""Check command line options"""
|
||||
_usage="""
|
||||
|
|
@ -597,7 +597,7 @@ class BridgeConstructor:
|
|||
help=("Add debug information printing"))
|
||||
parser.add_option("--no_unicode", action="store_false", dest="unicode", default=True,
|
||||
help=("Remove unicode type protection from string results"))
|
||||
parser.add_option("--flags", action="store", type="string",
|
||||
parser.add_option("--flags", action="store", type="string",
|
||||
help=("Constructors' specific flags, comma separated"))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ doc=New contact received in roster
|
|||
doc_param_0=contact_jid: JID from who the message is comming
|
||||
doc_param_1=attributes: Dictionary of attributes where keys are:
|
||||
- name: name of the contact
|
||||
- to: "True" if the contact give its presence information to us
|
||||
- to: "True" if the contact give its presence information to us
|
||||
- from: "True" if contact is registred to our presence information
|
||||
- ask: "True" is subscription is pending
|
||||
doc_param_2=groups: Roster's groups where the contact is
|
||||
|
|
@ -135,7 +135,7 @@ category=core
|
|||
sig_in=ssa{sa{ss}}s
|
||||
doc=Requested result of an action (Extended)
|
||||
doc_param_0=answer_type: Same as for [actionResult] but with the following additional one:
|
||||
- DICT_DICT: As RESULT, but returned as a dictionary of dictionary
|
||||
- DICT_DICT: As RESULT, but returned as a dictionary of dictionary
|
||||
doc_param_1=id: Id of the action
|
||||
doc_param_2=data: answer_type specific data
|
||||
doc_param_3=%(doc_profile)s
|
||||
|
|
@ -319,7 +319,7 @@ param_0_default="@DEFAULT@"
|
|||
doc=Return presence informations of all contacts
|
||||
doc_param_0=%(doc_profile_key)s
|
||||
doc_return=Dict of presence with bare JID of contact as key, and value as follow:
|
||||
A dict where key is the resource and the value is a tuple with (show, priority, statuses) as for [presenceUpdate]
|
||||
A dict where key is the resource and the value is a tuple with (show, priority, statuses) as for [presenceUpdate]
|
||||
|
||||
[getWaitingSub]
|
||||
type=method
|
||||
|
|
@ -552,7 +552,7 @@ doc_param_0=id: id of the progression status
|
|||
doc_param_1=%(doc_profile)s
|
||||
doc_return=dict with progress information:
|
||||
- position: current position
|
||||
- size: end position
|
||||
- size: end position
|
||||
|
||||
[getMenus]
|
||||
type=method
|
||||
|
|
@ -564,7 +564,7 @@ doc_return=list of tuple with the following value:
|
|||
- category: Category of the menu
|
||||
- name: Name of the menu
|
||||
- menu_type: Type which can be:
|
||||
* NORMAL: Classical application menu
|
||||
* NORMAL: Classical application menu
|
||||
|
||||
[getMenuHelp]
|
||||
type=method
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class DbusObject(dbus.service.Object):
|
|||
raise DeferredNotAsync
|
||||
return result
|
||||
|
||||
### signals ###
|
||||
### signals ###
|
||||
|
||||
@dbus.service.signal(const_INT_PREFIX+const_PLUGIN_SUFFIX,
|
||||
signature='')
|
||||
|
|
@ -106,14 +106,14 @@ class DbusObject(dbus.service.Object):
|
|||
|
||||
##SIGNALS_PART##
|
||||
|
||||
### methods ###
|
||||
|
||||
### methods ###
|
||||
|
||||
##METHODS_PART##
|
||||
|
||||
|
||||
def __attributes(self, in_sign):
|
||||
"""Return arguments to user given a in_sign
|
||||
@param in_sign: in_sign in the short form (using s,a,i,b etc)
|
||||
@return: list of arguments that correspond to a in_sign (e.g.: "sss" return "arg1, arg2, arg3")"""
|
||||
@return: list of arguments that correspond to a in_sign (e.g.: "sss" return "arg1, arg2, arg3")"""
|
||||
i=0
|
||||
idx=0
|
||||
attr=[]
|
||||
|
|
@ -152,19 +152,19 @@ class DbusObject(dbus.service.Object):
|
|||
|
||||
_arguments = inspect_args.args
|
||||
_defaults = list(inspect_args.defaults or [])
|
||||
|
||||
|
||||
if inspect.ismethod(method):
|
||||
#if we have a method, we don't want the first argument (usually 'self')
|
||||
del(_arguments[0])
|
||||
|
||||
#first arguments are for the _callback method
|
||||
arguments_callback = ', '.join([repr(name)] + ((_arguments + ['callback=callback','errback=errback']) if async else _arguments))
|
||||
|
||||
|
||||
if async:
|
||||
_arguments.extend(['callback','errback'])
|
||||
_defaults.extend([None, None])
|
||||
|
||||
|
||||
|
||||
|
||||
#now we create a second list with default values
|
||||
for i in range(1, len(_defaults)+1):
|
||||
_arguments[-i] = "%s = %s" % (_arguments[-i], repr(_defaults[-i]))
|
||||
|
|
@ -182,7 +182,7 @@ class DbusObject(dbus.service.Object):
|
|||
function = getattr(self, name)
|
||||
func_table = self._dbus_class_table[self.__class__.__module__ + '.' + self.__class__.__name__][function._dbus_interface]
|
||||
func_table[function.__name__] = function #Needed for introspection
|
||||
|
||||
|
||||
def addSignal(self, name, int_suffix, signature, doc={}):
|
||||
"""Dynamically add a signal to Dbus Bridge"""
|
||||
attributes = ', '.join(self.__attributes(signature))
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class DBusBridgeFrontend(BridgeFrontend):
|
|||
# - or if the last two arguments are callable
|
||||
|
||||
async = False
|
||||
|
||||
|
||||
if kwargs:
|
||||
if 'callback' in kwargs and 'errback' in kwargs:
|
||||
async = True
|
||||
|
|
@ -84,26 +84,26 @@ class DBusBridgeFrontend(BridgeFrontend):
|
|||
args = list(args)
|
||||
_errback = args.pop()
|
||||
_callback = args.pop()
|
||||
|
||||
|
||||
method = getattr(self.db_plugin_iface, name)
|
||||
|
||||
|
||||
if async:
|
||||
kwargs['reply_handler'] = _callback
|
||||
kwargs['error_handler'] = lambda err:_errback(err._dbus_error_name[len(const_ERROR_PREFIX)+1:])
|
||||
|
||||
return method(*args, **kwargs)
|
||||
|
||||
|
||||
return getPluginMethod
|
||||
|
||||
##METHODS_PART##
|
||||
|
||||
#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
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue