massive refactoring to switch from camelCase to snake_case:

historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a
pre-PEP8 code, to use the same coding style as in Twisted.

However, snake_case is more readable and it's better to follow PEP8 best practices, so it
has been decided to move on full snake_case. Because Libervia has a huge codebase, this
ended with a ugly mix of camelCase and snake_case.

To fix that, this patch does a big refactoring by renaming every function and method
(including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case.

This is a massive change, and may result in some bugs.
This commit is contained in:
Goffi 2023-04-08 13:54:42 +02:00
commit 6a6f15707a
278 changed files with 9945 additions and 9945 deletions

View file

@ -384,7 +384,7 @@ like this:
The encoding is explained in the documentation of the following method: The encoding is explained in the documentation of the following method:
.. automethod:: sat.plugins.plugin_comp_ap_gateway.APGateway.getJIDAndNode .. automethod:: sat.plugins.plugin_comp_ap_gateway.APGateway.get_jid_and_node
.. [#AP_chars] Most if not all AP implementations use webfinger `acct` URI as a de-facto .. [#AP_chars] Most if not all AP implementations use webfinger `acct` URI as a de-facto
@ -859,10 +859,10 @@ Using the Component (for developers)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Publication of AP items can be tested using the following method (with can be accessed Publication of AP items can be tested using the following method (with can be accessed
through the ``APSend`` bridge method, client is then replaced by the ``profile`` name, as through the ``ap_send`` bridge method, client is then replaced by the ``profile`` name, as
last argument): last argument):
.. automethod:: sat.plugins.plugin_comp_ap_gateway.APGateway.publishMessage .. automethod:: sat.plugins.plugin_comp_ap_gateway.APGateway.publish_message
The method can be used either with CLI's :ref:`debug bridge method The method can be used either with CLI's :ref:`debug bridge method
<li_debug_bridge_method>` or with any D-Bus tool like ``qdbus`` or ``d-feet`` (only if you <li_debug_bridge_method>` or with any D-Bus tool like ``qdbus`` or ``d-feet`` (only if you
@ -875,7 +875,7 @@ On its ``example.net`` Mastodon instance, Pierre has published a message with th
``https://example.net/@pierre/106986412193109832``. To send a reply to this message, ``https://example.net/@pierre/106986412193109832``. To send a reply to this message,
Louise can use the following command:: Louise can use the following command::
$ li debug bridge method -c APSend '"{\"node\": \"https://example.net/@pierre/106986412193109832\", \"content\": \"A lille hello from XMPP\"}","pierre\\40example.net@ap.example.org", "louise"' $ li debug bridge method -c ap_send '"{\"node\": \"https://example.net/@pierre/106986412193109832\", \"content\": \"A lille hello from XMPP\"}","pierre\\40example.net@ap.example.org", "louise"'
Note the double escaping, one for the shell argument, and the other to specify JSON Note the double escaping, one for the shell argument, and the other to specify JSON
object. object.

View file

@ -60,9 +60,9 @@ To save resources, not all nodes are fully cached. When a node is checked, a ser
analysers are checked, and the first one matching is used to determine if the node must be analysers are checked, and the first one matching is used to determine if the node must be
synchronised or not. synchronised or not.
Analysers can be registered by any plugins using ``registerAnalyser`` method: Analysers can be registered by any plugins using ``register_analyser`` method:
.. automethod:: sat.plugins.plugin_pubsub_cache.PubsubCache.registerAnalyser .. automethod:: sat.plugins.plugin_pubsub_cache.PubsubCache.register_analyser
If no analyser is found, ``to_sync`` is false, or an error happens during the caching, If no analyser is found, ``to_sync`` is false, or an error happens during the caching,
the node won't be synchronised and the pubsub service will always be requested. the node won't be synchronised and the pubsub service will always be requested.

View file

@ -333,11 +333,11 @@ Get description of ``dotclear`` importer::
$ li blog import dotclear $ li blog import dotclear
Import a Dotclear blog:: import a Dotclear blog::
$ li blog import dotclear /path/to/dotclear.dump $ li blog import dotclear /path/to/dotclear.dump
Import a Dotclear blog without uploading images:: import a Dotclear blog without uploading images::
$ li blog import --no-images-upload dotclear /path/to/dotclear.dump $ li blog import --no-images-upload dotclear /path/to/dotclear.dump

View file

@ -17,7 +17,7 @@ Python arguments as many shell arguments, or put them in a single shell argument
You profile is automatically set if the method requires it (using the value of ``-p You profile is automatically set if the method requires it (using the value of ``-p
PROFILE, --profile PROFILE``), so you must not specify it as an extra argument. PROFILE, --profile PROFILE``), so you must not specify it as an extra argument.
You can refer to `Bridge API documentation`_ to get core methods signatures You can refer to `bridge API documentation`_ to get core methods signatures
.. _Bridge API documentation: https://wiki.goffi.org/wiki/Bridge_API .. _Bridge API documentation: https://wiki.goffi.org/wiki/Bridge_API
@ -26,12 +26,12 @@ examples
-------- --------
Send a message using a single shell arguments for all Python arguments. We Send a message using a single shell arguments for all Python arguments. We
use first the method name (``messageSend``), then the required arguments (see `Bridge use first the method name (``message_send``), then the required arguments (see `bridge
API documentation`_ for details), without the profile as it is automatically set. We API documentation`_ for details), without the profile as it is automatically set. We
specify them as Python in one shell argument, so we use single quote (``\```)first for specify them as Python in one shell argument, so we use single quote (``\```)first for
s hell string, and inside it we use double quote (``"``) for Python strings:: s hell string, and inside it we use double quote (``"``) for Python strings::
$ li debug bridge method messageSend '"louise@example.org", {"": "test message"}, {}, "auto", {}' $ li debug bridge method message_send '"louise@example.org", {"": "test message"}, {}, "auto", {}'
.. note:: .. note::
@ -39,7 +39,7 @@ s hell string, and inside it we use double quote (``"``) for Python strings::
Get version string of Libervia:: Get version string of Libervia::
$ li debug bridge method getVersion $ li debug bridge method version_get
bridge signal bridge signal
@ -56,7 +56,7 @@ Send a note with ``info`` level and hand written XMLUI. Here me use a shell vari
store the level, so we can easily change it if we want to use an other level for tests. store the level, so we can easily change it if we want to use an other level for tests.
Note the use of quotes (to escape both for shell and Python):: Note the use of quotes (to escape both for shell and Python)::
$ LEVEL='info'; li debug bridge signal -c actionNew '{"xmlui": '"'"'<?xml version="1.0" ?><sat_xmlui title="test title" type="dialog"><dialog level="'$LEVEL'" type="note"><message>test message\non\nseveral\nlines</message></dialog></sat_xmlui>'"'"'}' '""' -1 $ LEVEL='info'; li debug bridge signal -c action_new '{"xmlui": '"'"'<?xml version="1.0" ?><sat_xmlui title="test title" type="dialog"><dialog level="'$LEVEL'" type="note"><message>test message\non\nseveral\nlines</message></dialog></sat_xmlui>'"'"'}' '""' -1
monitor monitor

View file

@ -35,10 +35,10 @@ Create a new event. You can specify the starting time of the event with ``-S TIM
If your organsise an item, the ``--rsvp`` flag should be used: it will use the default If your organsise an item, the ``--rsvp`` flag should be used: it will use the default
RSVP form which ask for attendance. If you want to request more information to your guest, RSVP form which ask for attendance. If you want to request more information to your guest,
``--rsvp_json JSON`` can be used: the JSON argument is a data dict as described in ``--rsvp_json JSON`` can be used: the JSON argument is a data dict as described in
``dataDict2dataForm`` function where the ``namespace`` key is not necessary (it's set ``data_dict_2_data_form`` function where the ``namespace`` key is not necessary (it's set
automatically): automatically):
.. autofunction:: sat.tools.xml_tools.dataDict2dataForm .. autofunction:: sat.tools.xml_tools.data_dict_2_data_form
If the event links to an other one, ``--external JID NODE ITEM`` can be user If the event links to an other one, ``--external JID NODE ITEM`` can be user

View file

@ -68,7 +68,7 @@ Delete item with id ``456`` from tickets on PubSub service ``pubsub.example.org`
import import
====== ======
Import lists from an external source. This works in the same way as import lists from an external source. This works in the same way as
:ref:`libervia-cli_blog_import`: you need to specify an importer and a data location. If you let :ref:`libervia-cli_blog_import`: you need to specify an importer and a data location. If you let
both positional argument empty, you'll get list of importers, if you specify importer but both positional argument empty, you'll get list of importers, if you specify importer but
not data location, you'll get a description on how the importer works. not data location, you'll get a description on how the importer works.
@ -99,7 +99,7 @@ Get description of list importer for Bugzilla::
$ li list import bugzilla $ li list import bugzilla
Import lists from a Bugzilla XML export file at ``~/bugzilla_export.xml`` to the import lists from a Bugzilla XML export file at ``~/bugzilla_export.xml`` to the
``pubsub.example.org`` PubSub service. We use default lists node and want a progression ``pubsub.example.org`` PubSub service. We use default lists node and want a progression
bar:: bar::

View file

@ -66,7 +66,7 @@ Display details for merge request with id 456::
import import
====== ======
Import a merge request into your project. You mainly have to be in the project repository import a merge request into your project. You mainly have to be in the project repository
(or specify it using ``-r PATH, --repository PATH``) and to specify the id of the patch to (or specify it using ``-r PATH, --repository PATH``) and to specify the id of the patch to
import (using ``-i ITEM, --item ITEM``). The behaviour depends of the type of the patch, import (using ``-i ITEM, --item ITEM``). The behaviour depends of the type of the patch,
for Mercurial, the patch will be imported as `MQ`_ patch. for Mercurial, the patch will be imported as `MQ`_ patch.
@ -76,6 +76,6 @@ for Mercurial, the patch will be imported as `MQ`_ patch.
example example
------- -------
Import the merge request with id 321:: import the merge request with id 321::
$ li merge-request import -i 321 $ li merge-request import -i 321

View file

@ -93,7 +93,7 @@ Make the ``public_notes`` node accessible to the world::
import import
====== ======
Import a raw XML containing items to create in the node. The path to the XML file is used import a raw XML containing items to create in the node. The path to the XML file is used
as positional argument. as positional argument.
The XML file must contain full `<item>` element for each item to import. The output of ``pubsub get`` can be used directly. The XML file must contain full `<item>` element for each item to import. The output of ``pubsub get`` can be used directly.
@ -103,7 +103,7 @@ If you want to change publisher of one or more items (i.e. if you want to use an
example example
------- -------
Import a node backup which has previously been saved using ``li blog get -M -1 -n import a node backup which has previously been saved using ``li blog get -M -1 -n
some_node > some_node_backup.xml``:: some_node > some_node_backup.xml``::
$ li pubsub node import -n some_node ~/some_node_backup.xml $ li pubsub node import -n some_node ~/some_node_backup.xml

View file

@ -74,7 +74,7 @@ class Constructor(object):
function[option] = value function[option] = value
return function return function
def getDefault(self, name): def get_default(self, name):
"""Return default values of a function in a dict """Return default values of a function in a dict
@param name: Name of the function to get @param name: Name of the function to get
@return: dict, each key is the integer param number (no key if no default value)""" @return: dict, each key is the integer param number (no key if no default value)"""
@ -106,7 +106,7 @@ class Constructor(object):
flags.append(option) flags.append(option)
return flags return flags
def getArgumentsDoc(self, name): def get_arguments_doc(self, name):
"""Return documentation of arguments """Return documentation of arguments
@param name: Name of the function to get @param name: Name of the function to get
@return: dict, each key is the integer param number (no key if no argument doc), value is a tuple (name, doc)""" @return: dict, each key is the integer param number (no key if no argument doc), value is a tuple (name, doc)"""
@ -131,7 +131,7 @@ class Constructor(object):
doc_dict[idx] = (value_match.group(1), value_match.group(2)) doc_dict[idx] = (value_match.group(1), value_match.group(2))
return doc_dict return doc_dict
def getDoc(self, name): def get_doc(self, name):
"""Return documentation of the method """Return documentation of the method
@param name: Name of the function to get @param name: Name of the function to get
@return: string documentation, or None""" @return: string documentation, or None"""
@ -139,7 +139,7 @@ class Constructor(object):
return self.bridge_template.get(name, "doc") return self.bridge_template.get(name, "doc")
return None return None
def argumentsParser(self, signature): def arguments_parser(self, signature):
"""Generator which return individual arguments signatures from a global signature""" """Generator which return individual arguments signatures from a global signature"""
start = 0 start = 0
i = 0 i = 0
@ -176,19 +176,19 @@ class Constructor(object):
yield signature[start:i] yield signature[start:i]
start = i start = i
def getArguments(self, signature, name=None, default=None, unicode_protect=False): def get_arguments(self, signature, name=None, default=None, unicode_protect=False):
"""Return arguments to user given a signature """Return arguments to user given a signature
@param signature: signature in the short form (using s,a,i,b etc) @param signature: signature in the short form (using s,a,i,b etc)
@param name: dictionary of arguments name like given by getArgumentsDoc @param name: dictionary of arguments name like given by get_arguments_doc
@param default: dictionary of default values, like given by getDefault @param default: dictionary of default values, like given by get_default
@param unicode_protect: activate unicode protection on strings (return strings as unicode(str)) @param unicode_protect: activate unicode protection on strings (return strings as unicode(str))
@return (str): arguments that correspond to a signature (e.g.: "sss" return "arg1, arg2, arg3") @return (str): arguments that correspond to a signature (e.g.: "sss" return "arg1, arg2, arg3")
""" """
idx = 0 idx = 0
attr_string = [] attr_string = []
for arg in self.argumentsParser(signature): for arg in self.arguments_parser(signature):
attr_string.append( attr_string.append(
( (
"str(%(name)s)%(default)s" "str(%(name)s)%(default)s"
@ -206,7 +206,7 @@ class Constructor(object):
return ", ".join(attr_string) return ", ".join(attr_string)
def getTemplatePath(self, template_file): def get_template_path(self, template_file):
"""return template path corresponding to file name """return template path corresponding to file name
@param template_file(str): name of template file @param template_file(str): name of template file
@ -232,12 +232,12 @@ class Constructor(object):
def generate(self, side): def generate(self, side):
"""generate bridge """generate bridge
call generateCoreSide or generateFrontendSide if they exists call generate_core_side or generateFrontendSide if they exists
else call generic self._generate method else call generic self._generate method
""" """
try: try:
if side == "core": if side == "core":
method = self.generateCoreSide method = self.generate_core_side
elif side == "frontend": elif side == "frontend":
if not self.FRONTEND_ACTIVATE: if not self.FRONTEND_ACTIVATE:
print("This constructor only handle core, please use core side") print("This constructor only handle core, please use core side")
@ -272,8 +272,8 @@ class Constructor(object):
for section in sections: for section in sections:
function = self.getValues(section) function = self.getValues(section)
print(("Adding %s %s" % (section, function["type"]))) print(("Adding %s %s" % (section, function["type"])))
default = self.getDefault(section) default = self.get_default(section)
arg_doc = self.getArgumentsDoc(section) arg_doc = self.get_arguments_doc(section)
async_ = "async" in self.getFlags(section) async_ = "async" in self.getFlags(section)
completion = { completion = {
"sig_in": function["sig_in"] or "", "sig_in": function["sig_in"] or "",
@ -281,10 +281,10 @@ class Constructor(object):
"category": "plugin" if function["category"] == "plugin" else "core", "category": "plugin" if function["category"] == "plugin" else "core",
"name": section, "name": section,
# arguments with default values # arguments with default values
"args": self.getArguments( "args": self.get_arguments(
function["sig_in"], name=arg_doc, default=default function["sig_in"], name=arg_doc, default=default
), ),
"args_no_default": self.getArguments(function["sig_in"], name=arg_doc), "args_no_default": self.get_arguments(function["sig_in"], name=arg_doc),
} }
extend_method = getattr( extend_method = getattr(
@ -305,7 +305,7 @@ class Constructor(object):
for env, v in os.environ.items() for env, v in os.environ.items()
if env.startswith(C.ENV_OVERRIDE) if env.startswith(C.ENV_OVERRIDE)
} }
template_path = self.getTemplatePath(TEMPLATE) template_path = self.get_template_path(TEMPLATE)
try: try:
with open(template_path) as template: with open(template_path) as template:
for line in template: for line in template:
@ -332,9 +332,9 @@ class Constructor(object):
sys.exit(1) sys.exit(1)
# now we write to final file # now we write to final file
self.finalWrite(DEST, bridge) self.final_write(DEST, bridge)
def finalWrite(self, filename, file_buf): def final_write(self, filename, file_buf):
"""Write the final generated file in [dest dir]/filename """Write the final generated file in [dest dir]/filename
@param filename: name of the file to generate @param filename: name of the file to generate

View file

@ -32,7 +32,7 @@ __version__ = C.APP_VERSION
class BridgeConstructor(object): class BridgeConstructor(object):
def importConstructors(self): def import_constructors(self):
constructors_dir = os.path.dirname(constructors.__file__) constructors_dir = os.path.dirname(constructors.__file__)
self.protocoles = {} self.protocoles = {}
for dir_ in os.listdir(constructors_dir): for dir_ in os.listdir(constructors_dir):
@ -120,7 +120,7 @@ class BridgeConstructor(object):
return parser.parse_args() return parser.parse_args()
def go(self): def go(self):
self.importConstructors() self.import_constructors()
args = self.parse_args() args = self.parse_args()
template_parser = Parser() template_parser = Parser()
try: try:

View file

@ -20,7 +20,7 @@ sig_in=s
doc=Connection is finished or lost doc=Connection is finished or lost
doc_param_0=%(doc_profile)s doc_param_0=%(doc_profile)s
[newContact] [contact_new]
type=signal type=signal
category=core category=core
sig_in=sa{ss}ass sig_in=sa{ss}ass
@ -34,7 +34,7 @@ doc_param_1=attributes: Dictionary of attributes where keys are:
doc_param_2=groups: Roster's groups where the contact is doc_param_2=groups: Roster's groups where the contact is
doc_param_3=%(doc_profile)s doc_param_3=%(doc_profile)s
[messageNew] [message_new]
type=signal type=signal
category=core category=core
sig_in=sdssa{ss}a{ss}sss sig_in=sdssa{ss}a{ss}sss
@ -54,7 +54,7 @@ doc_param_7=extra: extra message information, can have data added by plugins and
- info_type: subtype for info messages - info_type: subtype for info messages
doc_param_8=%(doc_profile)s doc_param_8=%(doc_profile)s
[messageEncryptionStarted] [message_encryption_started]
type=signal type=signal
category=core category=core
sig_in=sss sig_in=sss
@ -68,7 +68,7 @@ doc_param_1=encryption_data: (JSON_OBJ) data of the encryption algorithm used, e
- directed_devices: list or resource where session is encrypted - directed_devices: list or resource where session is encrypted
doc_param_2=%(doc_profile_key)s doc_param_2=%(doc_profile_key)s
[messageEncryptionStopped] [message_encryption_stopped]
type=signal type=signal
category=core category=core
sig_in=sa{ss}s sig_in=sa{ss}s
@ -79,7 +79,7 @@ doc_param_1=encryption_data: data of the encryption algorithm stopped, has a lea
- namespace: namespace of the encryption plugin - namespace: namespace of the encryption plugin
doc_param_2=%(doc_profile_key)s doc_param_2=%(doc_profile_key)s
[presenceUpdate] [presence_update]
type=signal type=signal
category=core category=core
sig_in=ssia{ss}s sig_in=ssia{ss}s
@ -99,7 +99,7 @@ doc_param_0=sub_type: Subscription states (see RFC 6121 §3)
doc_param_1=entity_jid: JID from which the subscription is coming doc_param_1=entity_jid: JID from which the subscription is coming
doc_param_2=%(doc_profile)s doc_param_2=%(doc_profile)s
[paramUpdate] [param_update]
type=signal type=signal
category=core category=core
sig_in=ssss sig_in=ssss
@ -109,7 +109,7 @@ doc_param_1=value: New value of the parameter
doc_param_2=category: Category of the updated parameter doc_param_2=category: Category of the updated parameter
doc_param_3=%(doc_profile)s doc_param_3=%(doc_profile)s
[contactDeleted] [contact_deleted]
type=signal type=signal
category=core category=core
sig_in=ss sig_in=ss
@ -117,7 +117,7 @@ doc=A contact has been supressed from roster
doc_param_0=entity_jid: JID of the contact removed from roster doc_param_0=entity_jid: JID of the contact removed from roster
doc_param_1=%(doc_profile)s doc_param_1=%(doc_profile)s
[actionNew] [action_new]
type=signal type=signal
category=core category=core
sig_in=a{ss}sis sig_in=a{ss}sis
@ -137,7 +137,7 @@ doc_param_1=id: action id
doc_param_2=%(doc_security_limit)s doc_param_2=%(doc_security_limit)s
doc_param_3=%(doc_profile)s doc_param_3=%(doc_profile)s
[entityDataUpdated] [entity_data_updated]
type=signal type=signal
category=core category=core
sig_in=ssss sig_in=ssss
@ -147,7 +147,7 @@ doc_param_1=name: Name of the updated value
doc_param_2=value: New value doc_param_2=value: New value
doc_param_3=%(doc_profile)s doc_param_3=%(doc_profile)s
[progressStarted] [progress_started]
type=signal type=signal
category=core category=core
sig_in=sa{ss}s sig_in=sa{ss}s
@ -160,7 +160,7 @@ doc_param_1=metadata: dict of progress metadata, key can be:
C.META_TYPE_FILE: file transfer C.META_TYPE_FILE: file transfer
doc_param_2=%(doc_profile)s doc_param_2=%(doc_profile)s
[progressFinished] [progress_finished]
type=signal type=signal
category=core category=core
sig_in=sa{ss}s sig_in=sa{ss}s
@ -170,11 +170,11 @@ doc_param_1=metadata: dict of progress status metadata, key can be:
- hash: value of the computed hash - hash: value of the computed hash
- hash_algo: alrorithm used to compute hash - hash_algo: alrorithm used to compute hash
- hash_verified: C.BOOL_TRUE if hash is verified and OK - hash_verified: C.BOOL_TRUE if hash is verified and OK
C.BOOL_FALSE if hash was not received ([progressError] will be used if there is a mismatch) C.BOOL_FALSE if hash was not received ([progress_error] will be used if there is a mismatch)
- url: url linked to the progression (e.g. download url after a file upload) - url: url linked to the progression (e.g. download url after a file upload)
doc_param_2=%(doc_profile)s doc_param_2=%(doc_profile)s
[progressError] [progress_error]
type=signal type=signal
category=core category=core
sig_in=sss sig_in=sss
@ -194,7 +194,7 @@ doc_param_2=%(doc_profile)s
;methods ;methods
[getReady] [ready_get]
async= async=
type=method type=method
category=core category=core
@ -202,14 +202,14 @@ sig_in=
sig_out= sig_out=
doc=Return when backend is initialised doc=Return when backend is initialised
[getVersion] [version_get]
type=method type=method
category=core category=core
sig_in= sig_in=
sig_out=s sig_out=s
doc=Get "Salut à Toi" full version doc=Get "Salut à Toi" full version
[getFeatures] [features_get]
type=method type=method
category=core category=core
sig_in=s sig_in=s
@ -221,7 +221,7 @@ doc_return=dictionary of available features:
plugin import name is used as key, data is an other dict managed by the plugin plugin import name is used as key, data is an other dict managed by the plugin
async= async=
[profileNameGet] [profile_name_get]
type=method type=method
category=core category=core
sig_in=s sig_in=s
@ -231,7 +231,7 @@ doc=Get real profile name from profile key
doc_param_0=%(doc_profile_key)s doc_param_0=%(doc_profile_key)s
doc_return=Real profile name doc_return=Real profile name
[profilesListGet] [profiles_list_get]
type=method type=method
category=core category=core
sig_in=bb sig_in=bb
@ -242,7 +242,7 @@ doc_param_0=clients: get clients profiles
doc_param_1=components: get components profiles doc_param_1=components: get components profiles
doc=Get list of profiles doc=Get list of profiles
[profileSetDefault] [profile_set_default]
type=method type=method
category=core category=core
sig_in=s sig_in=s
@ -250,7 +250,7 @@ sig_out=
doc_param_0=%(doc_profile)s doc_param_0=%(doc_profile)s
doc=Set default profile doc=Set default profile
[getEntityData] [entity_data_get]
type=method type=method
category=core category=core
sig_in=sass sig_in=sass
@ -262,7 +262,7 @@ doc_param_2=%(doc_profile)s
doc_return=dictionary of asked key, doc_return=dictionary of asked key,
if key doesn't exist, the resulting dictionary will not have the key if key doesn't exist, the resulting dictionary will not have the key
[getEntitiesData] [entities_data_get]
type=method type=method
category=core category=core
sig_in=asass sig_in=asass
@ -275,7 +275,7 @@ doc_return=dictionary with jids as keys and dictionary of asked key as values
values are serialised values are serialised
if key doesn't exist for a jid, the resulting dictionary will not have it if key doesn't exist for a jid, the resulting dictionary will not have it
[profileCreate] [profile_create]
async= async=
type=method type=method
category=core category=core
@ -293,7 +293,7 @@ errback is called with error constant as parameter:
- CancelError: profile creation canceled - CancelError: profile creation canceled
- NotFound: component entry point is not available - NotFound: component entry point is not available
[asyncDeleteProfile] [profile_delete_async]
async= async=
type=method type=method
category=core category=core
@ -325,7 +325,7 @@ doc_return=a deferred boolean or failure:
- False if the XMPP connection has been initiated (it may still fail) - False if the XMPP connection has been initiated (it may still fail)
- failure if the profile authentication failed - failure if the profile authentication failed
[profileStartSession] [profile_start_session]
async= async=
type=method type=method
category=core category=core
@ -340,7 +340,7 @@ doc_return=D(bool):
- True if the profile session was already started - True if the profile session was already started
- False else - False else
[profileIsSessionStarted] [profile_is_session_started]
type=method type=method
category=core category=core
sig_in=s sig_in=s
@ -359,7 +359,7 @@ param_0_default="@DEFAULT@"
doc=Disconnect a profile doc=Disconnect a profile
doc_param_0=%(doc_profile_key)s doc_param_0=%(doc_profile_key)s
[isConnected] [is_connected]
type=method type=method
category=core category=core
sig_in=s sig_in=s
@ -368,7 +368,7 @@ param_0_default="@DEFAULT@"
doc=Tell if a profile is connected doc=Tell if a profile is connected
doc_param_0=%(doc_profile_key)s doc_param_0=%(doc_profile_key)s
[contactGet] [contact_get]
async= async=
type=method type=method
category=core category=core
@ -378,10 +378,10 @@ param_1_default="@DEFAULT@"
doc=Return informations in roster about a contact doc=Return informations in roster about a contact
doc_param_1=%(doc_profile_key)s doc_param_1=%(doc_profile_key)s
doc_return=tuple with the following values: doc_return=tuple with the following values:
- list of attributes as in [newContact] - list of attributes as in [contact_new]
- groups where the contact is - groups where the contact is
[getContacts] [contacts_get]
async= async=
type=method type=method
category=core category=core
@ -392,10 +392,10 @@ doc=Return information about all contacts (the roster)
doc_param_0=%(doc_profile_key)s doc_param_0=%(doc_profile_key)s
doc_return=array of tuples with the following values: doc_return=array of tuples with the following values:
- JID of the contact - JID of the contact
- list of attributes as in [newContact] - list of attributes as in [contact_new]
- groups where the contact is - groups where the contact is
[getContactsFromGroup] [contacts_get_from_group]
type=method type=method
category=core category=core
sig_in=ss sig_in=ss
@ -406,7 +406,7 @@ doc_param_0=group: name of the group to check
doc_param_1=%(doc_profile_key)s doc_param_1=%(doc_profile_key)s
doc_return=array of jids doc_return=array of jids
[getMainResource] [main_resource_get]
type=method type=method
category=core category=core
sig_in=ss sig_in=ss
@ -417,7 +417,7 @@ doc_param_0=contact_jid: jid of the contact
doc_param_1=%(doc_profile_key)s doc_param_1=%(doc_profile_key)s
doc_return=the resource connected of the contact with highest priority, or "" doc_return=the resource connected of the contact with highest priority, or ""
[getPresenceStatuses] [presence_statuses_get]
type=method type=method
category=core category=core
sig_in=s sig_in=s
@ -426,9 +426,9 @@ param_0_default="@DEFAULT@"
doc=Return presence information of all contacts doc=Return presence information of all contacts
doc_param_0=%(doc_profile_key)s doc_param_0=%(doc_profile_key)s
doc_return=Dict of presence with bare JID of contact as key, and value as follow: 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 [presence_update]
[getWaitingSub] [sub_waiting_get]
type=method type=method
category=core category=core
sig_in=s sig_in=s
@ -438,7 +438,7 @@ doc=Get subscription requests in queue
doc_param_0=%(doc_profile_key)s doc_param_0=%(doc_profile_key)s
doc_return=Dict where contact JID is the key, and value is the subscription type doc_return=Dict where contact JID is the key, and value is the subscription type
[messageSend] [message_send]
async= async=
type=method type=method
category=core category=core
@ -458,7 +458,7 @@ doc_param_3=mess_type: Type of the message (cf RFC 6121 §5.2.2) or "auto" for a
doc_param_4=extra: (serialised) optional data that can be used by a plugin to build more specific messages doc_param_4=extra: (serialised) optional data that can be used by a plugin to build more specific messages
doc_param_5=%(doc_profile_key)s doc_param_5=%(doc_profile_key)s
[messageEncryptionStart] [message_encryption_start]
async= async=
type=method type=method
category=core category=core
@ -474,7 +474,7 @@ doc_param_2=replace: if True and an encryption session already exists, it will b
else a ConflictError will be raised else a ConflictError will be raised
doc_param_3=%(doc_profile_key)s doc_param_3=%(doc_profile_key)s
[messageEncryptionStop] [message_encryption_stop]
async= async=
type=method type=method
category=core category=core
@ -484,7 +484,7 @@ doc=Stop an encryption session
doc_param_0=to_jid: JID of the recipient (full jid if encryption must be stopped for one device only) doc_param_0=to_jid: JID of the recipient (full jid if encryption must be stopped for one device only)
doc_param_1=%(doc_profile_key)s doc_param_1=%(doc_profile_key)s
[messageEncryptionGet] [message_encryption_get]
type=method type=method
category=core category=core
sig_in=ss sig_in=ss
@ -499,21 +499,21 @@ doc_return=(JSON_OBJ) empty string if session is unencrypted, else a json encode
following key can be present if suitable: following key can be present if suitable:
- directed_devices: list or resource where session is encrypted - directed_devices: list or resource where session is encrypted
[encryptionNamespaceGet] [encryption_namespace_get]
type=method type=method
category=core category=core
sig_in=s sig_in=s
sig_out=s sig_out=s
doc=Get algorithm namespace from its name doc=Get algorithm namespace from its name
[encryptionPluginsGet] [encryption_plugins_get]
type=method type=method
category=core category=core
sig_in= sig_in=
sig_out=s sig_out=s
doc=Retrieve registered plugins for encryption doc=Retrieve registered plugins for encryption
[encryptionTrustUIGet] [encryption_trust_ui_get]
async= async=
type=method type=method
category=core category=core
@ -525,7 +525,7 @@ doc_param_1=namespace: namespace of the algorithm to manage
doc_param_2=%(doc_profile_key)s doc_param_2=%(doc_profile_key)s
doc_return=(XMLUI) UI of the trust management doc_return=(XMLUI) UI of the trust management
[setPresence] [presence_set]
type=method type=method
category=core category=core
sig_in=ssa{ss}s sig_in=ssa{ss}s
@ -536,8 +536,8 @@ param_2_default={}
param_3_default="@DEFAULT@" param_3_default="@DEFAULT@"
doc=Set presence information for the profile doc=Set presence information for the profile
doc_param_0=to_jid: the JID to who we send the presence data (emtpy string for broadcast) doc_param_0=to_jid: the JID to who we send the presence data (emtpy string for broadcast)
doc_param_1=show: as for [presenceUpdate] doc_param_1=show: as for [presence_update]
doc_param_2=statuses: as for [presenceUpdate] doc_param_2=statuses: as for [presence_update]
doc_param_3=%(doc_profile_key)s doc_param_3=%(doc_profile_key)s
[subscription] [subscription]
@ -551,7 +551,7 @@ doc_param_0=sub_type: as for [subscribe]
doc_param_1=entity: as for [subscribe] doc_param_1=entity: as for [subscribe]
doc_param_2=%(doc_profile_key)s doc_param_2=%(doc_profile_key)s
[getConfig] [config_get]
type=method type=method
category=core category=core
sig_in=ss sig_in=ss
@ -560,7 +560,7 @@ doc=get main configuration option
doc_param_0=section: section of the configuration file (empty string for DEFAULT) doc_param_0=section: section of the configuration file (empty string for DEFAULT)
doc_param_1=name: name of the option doc_param_1=name: name of the option
[setParam] [param_set]
type=method type=method
category=core category=core
sig_in=sssis sig_in=sssis
@ -574,7 +574,7 @@ doc_param_2=category: Category of the parameter to change
doc_param_3=%(doc_security_limit)s doc_param_3=%(doc_security_limit)s
doc_param_4=%(doc_profile_key)s doc_param_4=%(doc_profile_key)s
[getParamA] [param_get_a]
type=method type=method
category=core category=core
sig_in=ssss sig_in=ssss
@ -582,12 +582,12 @@ sig_out=s
param_2_default="value" param_2_default="value"
param_3_default="@DEFAULT@" param_3_default="@DEFAULT@"
doc=Helper method to get a parameter's attribute *when profile is connected* doc=Helper method to get a parameter's attribute *when profile is connected*
doc_param_0=name: as for [setParam] doc_param_0=name: as for [param_set]
doc_param_1=category: as for [setParam] doc_param_1=category: as for [param_set]
doc_param_2=attribute: Name of the attribute doc_param_2=attribute: Name of the attribute
doc_param_3=%(doc_profile_key)s doc_param_3=%(doc_profile_key)s
[privateDataGet] [private_data_get]
async= async=
type=method type=method
category=core category=core
@ -599,7 +599,7 @@ doc_param_1=key: key of the data to set
doc_param_2=%(doc_profile_key)s doc_param_2=%(doc_profile_key)s
doc_return=serialised data doc_return=serialised data
[privateDataSet] [private_data_set]
async= async=
type=method type=method
category=core category=core
@ -611,7 +611,7 @@ doc_param_1=key: key of the data to set
doc_param_2=data: serialised data doc_param_2=data: serialised data
doc_param_3=%(doc_profile_key)s doc_param_3=%(doc_profile_key)s
[privateDataDelete] [private_data_delete]
async= async=
type=method type=method
category=core category=core
@ -622,7 +622,7 @@ doc_param_0=namespace: unique namespace to use
doc_param_1=key: key of the data to delete doc_param_1=key: key of the data to delete
doc_param_3=%(doc_profile_key)s doc_param_3=%(doc_profile_key)s
[asyncGetParamA] [param_get_a_async]
async= async=
type=method type=method
category=core category=core
@ -632,13 +632,13 @@ param_2_default="value"
param_3_default=-1 param_3_default=-1
param_4_default="@DEFAULT@" param_4_default="@DEFAULT@"
doc=Helper method to get a parameter's attribute doc=Helper method to get a parameter's attribute
doc_param_0=name: as for [setParam] doc_param_0=name: as for [param_set]
doc_param_1=category: as for [setParam] doc_param_1=category: as for [param_set]
doc_param_2=attribute: Name of the attribute doc_param_2=attribute: Name of the attribute
doc_param_3=%(doc_security_limit)s doc_param_3=%(doc_security_limit)s
doc_param_4=%(doc_profile_key)s doc_param_4=%(doc_profile_key)s
[asyncGetParamsValuesFromCategory] [params_values_from_category_get_async]
async= async=
type=method type=method
category=code category=code
@ -649,13 +649,13 @@ param_2_default=""
param_3_default="" param_3_default=""
param_4_default="@DEFAULT@" param_4_default="@DEFAULT@"
doc=Get "attribute" for all params of a category doc=Get "attribute" for all params of a category
doc_param_0=category: as for [setParam] doc_param_0=category: as for [param_set]
doc_param_1=%(doc_security_limit)s doc_param_1=%(doc_security_limit)s
doc_param_2=app: name of the frontend requesting the parameters, or '' to get all parameters doc_param_2=app: name of the frontend requesting the parameters, or '' to get all parameters
doc_param_3=extra: extra options/filters doc_param_3=extra: extra options/filters
doc_param_4=%(doc_profile_key)s doc_param_4=%(doc_profile_key)s
[getParamsUI] [param_ui_get]
async= async=
type=method type=method
category=core category=core
@ -671,7 +671,7 @@ doc_param_1=app: name of the frontend requesting the parameters, or '' to get al
doc_param_2=extra: extra options/filters doc_param_2=extra: extra options/filters
doc_param_3=%(doc_profile_key)s doc_param_3=%(doc_profile_key)s
[getParamsCategories] [params_categories_get]
type=method type=method
category=core category=core
sig_in= sig_in=
@ -679,7 +679,7 @@ sig_out=as
doc=Get all categories currently existing in parameters doc=Get all categories currently existing in parameters
doc_return=list of categories doc_return=list of categories
[paramsRegisterApp] [params_register_app]
type=method type=method
category=core category=core
sig_in=sis sig_in=sis
@ -691,7 +691,7 @@ doc_param_0=xml: XML definition of the parameters to be added
doc_param_1=%(doc_security_limit)s doc_param_1=%(doc_security_limit)s
doc_param_2=app: name of the frontend registering the parameters doc_param_2=app: name of the frontend registering the parameters
[historyGet] [history_get]
async= async=
type=method type=method
category=core category=core
@ -712,9 +712,9 @@ doc_param_4=filters: patterns to filter the history results, can be:
- not_types: type must not be one of those, values are separated by spaces - not_types: type must not be one of those, values are separated by spaces
- before_uid: check only message received before message with given uid - before_uid: check only message received before message with given uid
doc_param_5=%(doc_profile)s doc_param_5=%(doc_profile)s
doc_return=Ordered list (by timestamp) of data as in [messageNew] (without final profile) doc_return=Ordered list (by timestamp) of data as in [message_new] (without final profile)
[addContact] [contact_add]
type=method type=method
category=core category=core
sig_in=ss sig_in=ss
@ -724,7 +724,7 @@ doc=Add a contact to profile's roster
doc_param_0=entity_jid: JID to add to roster doc_param_0=entity_jid: JID to add to roster
doc_param_1=%(doc_profile_key)s doc_param_1=%(doc_profile_key)s
[updateContact] [contact_update]
type=method type=method
category=core category=core
sig_in=ssass sig_in=ssass
@ -736,7 +736,7 @@ doc_param_1=name: roster's name for the entity
doc_param_2=groups: list of group where the entity is doc_param_2=groups: list of group where the entity is
doc_param_3=%(doc_profile_key)s doc_param_3=%(doc_profile_key)s
[delContact] [contact_del]
async= async=
type=method type=method
category=core category=core
@ -747,7 +747,7 @@ doc=Remove a contact from profile's roster
doc_param_0=entity_jid: JID to remove from roster doc_param_0=entity_jid: JID to remove from roster
doc_param_1=%(doc_profile_key)s doc_param_1=%(doc_profile_key)s
[rosterResync] [roster_resync]
async= async=
type=method type=method
category=core category=core
@ -757,7 +757,7 @@ param_0_default="@DEFAULT@"
doc=Do a full resynchronisation of roster with server doc=Do a full resynchronisation of roster with server
doc_param_0=%(doc_profile_key)s doc_param_0=%(doc_profile_key)s
[launchAction] [action_launch]
async= async=
type=method type=method
category=core category=core
@ -771,7 +771,7 @@ doc_param_2=%(doc_profile_key)s
doc_return=dict where key can be: doc_return=dict where key can be:
- xmlui: a XMLUI need to be displayed - xmlui: a XMLUI need to be displayed
[actionsGet] [actions_get]
type=method type=method
category=core category=core
sig_in=s sig_in=s
@ -779,9 +779,9 @@ sig_out=a(a{ss}si)
param_0_default="@DEFAULT@" param_0_default="@DEFAULT@"
doc=Get all not yet answered actions doc=Get all not yet answered actions
doc_param_0=%(doc_profile_key)s doc_param_0=%(doc_profile_key)s
doc_return=list of data as for [actionNew] (without the profile) doc_return=list of data as for [action_new] (without the profile)
[progressGet] [progress_get]
type=method type=method
category=core category=core
sig_in=ss sig_in=ss
@ -794,7 +794,7 @@ doc_return=dict with progress informations:
- size: end position (optional if not known) - size: end position (optional if not known)
other metadata may be present other metadata may be present
[progressGetAllMetadata] [progress_get_all_metadata]
type=method type=method
category=core category=core
sig_in=s sig_in=s
@ -803,9 +803,9 @@ doc=Get all active progress informations
doc_param_0=%(doc_profile)s or C.PROF_KEY_ALL for all profiles doc_param_0=%(doc_profile)s or C.PROF_KEY_ALL for all profiles
doc_return= a dict which map profile to progress_dict doc_return= a dict which map profile to progress_dict
progress_dict map progress_id to progress_metadata progress_dict map progress_id to progress_metadata
progress_metadata is the same dict as sent by [progressStarted] progress_metadata is the same dict as sent by [progress_started]
[progressGetAll] [progress_get_all]
type=method type=method
category=core category=core
sig_in=s sig_in=s
@ -814,9 +814,9 @@ doc=Get all active progress informations
doc_param_0=%(doc_profile)s or C.PROF_KEY_ALL for all profiles doc_param_0=%(doc_profile)s or C.PROF_KEY_ALL for all profiles
doc_return= a dict which map profile to progress_dict doc_return= a dict which map profile to progress_dict
progress_dict map progress_id to progress_data progress_dict map progress_id to progress_data
progress_data is the same dict as returned by [progressGet] progress_data is the same dict as returned by [progress_get]
[menusGet] [menus_get]
type=method type=method
category=core category=core
sig_in=si sig_in=si
@ -832,7 +832,7 @@ doc_return=list of tuple with the following value:
- menu_path_i18n: translated path of the menu - menu_path_i18n: translated path of the menu
- extra: extra data, like icon name - extra: extra data, like icon name
[menuLaunch] [menu_launch]
async= async=
type=method type=method
category=core category=core
@ -847,7 +847,7 @@ doc_param_4=%(doc_profile_key)s
doc_return=dict where key can be: doc_return=dict where key can be:
- xmlui: a XMLUI need to be displayed - xmlui: a XMLUI need to be displayed
[menuHelpGet] [menu_help_get]
type=method type=method
category=core category=core
sig_in=ss sig_in=ss
@ -858,7 +858,7 @@ doc_param_0=menu_id: id of the menu (same as callback_id)
doc_param_1=language: language in which the menu should be translated (empty string for default) doc_param_1=language: language in which the menu should be translated (empty string for default)
doc_return=Translated help string doc_return=Translated help string
[discoInfos] [disco_infos]
async= async=
type=method type=method
category=core category=core
@ -884,7 +884,7 @@ doc_return=discovery data:
* desc * desc
- list of values - list of values
[discoItems] [disco_items]
async= async=
type=method type=method
category=core category=core
@ -900,7 +900,7 @@ doc_param_2=use_cache: use cached data if available
doc_param_3=%(doc_profile_key)s doc_param_3=%(doc_profile_key)s
doc_return=array of tuple (entity, node identifier, name) doc_return=array of tuple (entity, node identifier, name)
[discoFindByFeatures] [disco_find_by_features]
async= async=
type=method type=method
category=core category=core
@ -927,7 +927,7 @@ doc_return=tuple of maps of found entities full jids to their identities. Maps a
- own entities (i.e. entities linked to profile's jid) - own entities (i.e. entities linked to profile's jid)
- roster entities - roster entities
[saveParamsTemplate] [params_template_save]
type=method type=method
category=core category=core
sig_in=s sig_in=s
@ -936,7 +936,7 @@ doc=Save parameters template to xml file
doc_param_0=filename: output filename doc_param_0=filename: output filename
doc_return=boolean (True in case of success) doc_return=boolean (True in case of success)
[loadParamsTemplate] [params_template_load]
type=method type=method
category=core category=core
sig_in=s sig_in=s
@ -945,7 +945,7 @@ doc=Load parameters template from xml file
doc_param_0=filename: input filename doc_param_0=filename: input filename
doc_return=boolean (True in case of success) doc_return=boolean (True in case of success)
[sessionInfosGet] [session_infos_get]
async= async=
type=method type=method
category=core category=core
@ -957,7 +957,7 @@ doc_return=session informations, with at least the following keys:
jid: current full jid jid: current full jid
started: date of creation of the session (Epoch time) started: date of creation of the session (Epoch time)
[devicesInfosGet] [devices_infos_get]
async= async=
type=method type=method
category=core category=core
@ -970,7 +970,7 @@ doc_param_1=%(doc_profile_key)s
doc_return=list of known devices, where each item is a dict with a least following keys: doc_return=list of known devices, where each item is a dict with a least following keys:
resource: device resource resource: device resource
[namespacesGet] [namespaces_get]
type=method type=method
category=core category=core
sig_in= sig_in=
@ -978,7 +978,7 @@ sig_out=a{ss}
doc=Get a dict to short name => whole namespaces doc=Get a dict to short name => whole namespaces
doc_return=namespaces mapping doc_return=namespaces mapping
[imageCheck] [image_check]
type=method type=method
category=core category=core
sig_in=s sig_in=s
@ -986,7 +986,7 @@ sig_out=s
doc=Analyze an image a return a report doc=Analyze an image a return a report
doc_return=serialized report doc_return=serialized report
[imageResize] [image_resize]
async= async=
type=method type=method
category=core category=core
@ -999,7 +999,7 @@ doc_param_2=height: height of the new image
doc_return=path of the new image with desired size doc_return=path of the new image with desired size
the image must be deleted once not needed anymore the image must be deleted once not needed anymore
[imageGeneratePreview] [image_generate_preview]
async= async=
type=method type=method
category=core category=core
@ -1010,7 +1010,7 @@ doc_param_0=image_path: path of the original image
doc_param_1=%(doc_profile_key)s doc_param_1=%(doc_profile_key)s
doc_return=path to the preview in cache doc_return=path to the preview in cache
[imageConvert] [image_convert]
async= async=
type=method type=method
category=core category=core

View file

@ -38,9 +38,9 @@ class DbusXmlConstructor(base_constructor.Constructor):
"a{sa{s(sia{ss})}}": "PresenceStatusT", "a{sa{s(sia{ss})}}": "PresenceStatusT",
} }
def generateCoreSide(self): def generate_core_side(self):
try: try:
doc = minidom.parse(self.getTemplatePath(self.template)) doc = minidom.parse(self.get_template_path(self.template))
interface_elt = doc.getElementsByTagName("interface")[0] interface_elt = doc.getElementsByTagName("interface")[0]
except IOError: except IOError:
print("Can't access template") print("Can't access template")
@ -60,8 +60,8 @@ class DbusXmlConstructor(base_constructor.Constructor):
new_elt.setAttribute("name", section) new_elt.setAttribute("name", section)
idx = 0 idx = 0
args_doc = self.getArgumentsDoc(section) args_doc = self.get_arguments_doc(section)
for arg in self.argumentsParser(function["sig_in"] or ""): for arg in self.arguments_parser(function["sig_in"] or ""):
arg_elt = doc.createElement("arg") arg_elt = doc.createElement("arg")
arg_elt.setAttribute( arg_elt.setAttribute(
"name", args_doc[idx][0] if idx in args_doc else "arg_%i" % idx "name", args_doc[idx][0] if idx in args_doc else "arg_%i" % idx
@ -99,4 +99,4 @@ class DbusXmlConstructor(base_constructor.Constructor):
interface_elt.appendChild(new_elt) interface_elt.appendChild(new_elt)
# now we write to final file # now we write to final file
self.finalWrite(self.core_dest, [doc.toprettyxml()]) self.final_write(self.core_dest, [doc.toprettyxml()])

View file

@ -81,7 +81,7 @@ class DbusConstructor(base_constructor.Constructor):
"debug": "" "debug": ""
if not self.args.debug if not self.args.debug
else 'log.debug ("%s")\n%s' % (completion["name"], 8 * " "), else 'log.debug ("%s")\n%s' % (completion["name"], 8 * " "),
"args_result": self.getArguments(function["sig_in"], name=arg_doc), "args_result": self.get_arguments(function["sig_in"], name=arg_doc),
"async_args": "callback=None, errback=None", "async_args": "callback=None, errback=None",
"async_comma": ", " if function["sig_in"] else "", "async_comma": ", " if function["sig_in"] else "",
"error_handler": """if callback is None: "error_handler": """if callback is None:

View file

@ -30,8 +30,8 @@ from txdbus.interface import DBusInterface, Method, Signal
log = getLogger(__name__) log = getLogger(__name__)
# Interface prefix # Interface prefix
const_INT_PREFIX = config.getConfig( const_INT_PREFIX = config.config_get(
config.parseMainConf(), config.parse_main_conf(),
"", "",
"bridge_dbus_int_prefix", "bridge_dbus_int_prefix",
"org.libervia.Libervia") "org.libervia.Libervia")
@ -118,13 +118,13 @@ class DBusObject(objects.DBusObject):
##METHODS_PART## ##METHODS_PART##
class Bridge: class bridge:
def __init__(self): def __init__(self):
log.info("Init DBus...") log.info("Init DBus...")
self._obj = DBusObject(const_OBJ_PATH) self._obj = DBusObject(const_OBJ_PATH)
async def postInit(self): async def post_init(self):
try: try:
conn = await client.connect(reactor) conn = await client.connect(reactor)
except error.DBusException as e: except error.DBusException as e:
@ -145,13 +145,13 @@ class Bridge:
log.debug(f"registering DBus bridge method [{name}]") log.debug(f"registering DBus bridge method [{name}]")
self._obj.register_method(name, callback) self._obj.register_method(name, callback)
def emitSignal(self, name, *args): def emit_signal(self, name, *args):
self._obj.emitSignal(name, *args) self._obj.emitSignal(name, *args)
def addMethod( def add_method(
self, name, int_suffix, in_sign, out_sign, method, async_=False, doc={} self, name, int_suffix, in_sign, out_sign, method, async_=False, doc={}
): ):
"""Dynamically add a method to D-Bus Bridge""" """Dynamically add a method to D-Bus bridge"""
# FIXME: doc parameter is kept only temporary, the time to remove it from calls # FIXME: doc parameter is kept only temporary, the time to remove it from calls
log.debug(f"Adding method {name!r} to D-Bus bridge") log.debug(f"Adding method {name!r} to D-Bus bridge")
self._obj.plugin_iface.addMethod( self._obj.plugin_iface.addMethod(
@ -164,8 +164,8 @@ class Bridge:
setattr(self._obj, f"dbus_{name}", MethodType(caller, self._obj)) setattr(self._obj, f"dbus_{name}", MethodType(caller, self._obj))
self.register_method(name, method) self.register_method(name, method)
def addSignal(self, name, int_suffix, signature, doc={}): def add_signal(self, name, int_suffix, signature, doc={}):
"""Dynamically add a signal to D-Bus Bridge""" """Dynamically add a signal to D-Bus bridge"""
log.debug(f"Adding signal {name!r} to D-Bus bridge") log.debug(f"Adding signal {name!r} to D-Bus bridge")
self._obj.plugin_iface.addSignal(Signal(name, signature)) self._obj.plugin_iface.addSignal(Signal(name, signature))
setattr(Bridge, name, partialmethod(Bridge.emitSignal, name)) setattr(bridge, name, partialmethod(bridge.emit_signal, name))

View file

@ -32,8 +32,8 @@ log = getLogger(__name__)
# Interface prefix # Interface prefix
const_INT_PREFIX = config.getConfig( const_INT_PREFIX = config.config_get(
config.parseMainConf(), config.parse_main_conf(),
"", "",
"bridge_dbus_int_prefix", "bridge_dbus_int_prefix",
"org.libervia.Libervia") "org.libervia.Libervia")
@ -66,9 +66,9 @@ def dbus_to_bridge_exception(dbus_e):
return BridgeException(name, message, condition) return BridgeException(name, message, condition)
class Bridge: class bridge:
def bridgeConnect(self, callback, errback): def bridge_connect(self, callback, errback):
try: try:
self.sessions_bus = dbus.SessionBus() self.sessions_bus = dbus.SessionBus()
self.db_object = self.sessions_bus.get_object(const_INT_PREFIX, self.db_object = self.sessions_bus.get_object(const_INT_PREFIX,
@ -105,7 +105,7 @@ class Bridge:
except AttributeError: except AttributeError:
# The attribute is not found, we try the plugin proxy to find the requested method # The attribute is not found, we try the plugin proxy to find the requested method
def getPluginMethod(*args, **kwargs): def get_plugin_method(*args, **kwargs):
# We first check if we have an async call. We detect this in two ways: # We first check if we have an async call. We detect this in two ways:
# - if we have the 'callback' and 'errback' keyword arguments # - if we have the 'callback' and 'errback' keyword arguments
# - or if the last two arguments are callable # - or if the last two arguments are callable
@ -156,11 +156,11 @@ class Bridge:
return self.db_plugin_iface.get_dbus_method(name)(*args, **kwargs) return self.db_plugin_iface.get_dbus_method(name)(*args, **kwargs)
raise e raise e
return getPluginMethod return get_plugin_method
##METHODS_PART## ##METHODS_PART##
class AIOBridge(Bridge): class AIOBridge(bridge):
def register_signal(self, functionName, handler, iface="core"): def register_signal(self, functionName, handler, iface="core"):
loop = asyncio.get_running_loop() loop = asyncio.get_running_loop()
@ -173,7 +173,7 @@ class AIOBridge(Bridge):
return object.__getattribute__(self, name) return object.__getattribute__(self, name)
except AttributeError: except AttributeError:
# The attribute is not found, we try the plugin proxy to find the requested method # The attribute is not found, we try the plugin proxy to find the requested method
def getPluginMethod(*args, **kwargs): def get_plugin_method(*args, **kwargs):
loop = asyncio.get_running_loop() loop = asyncio.get_running_loop()
fut = loop.create_future() fut = loop.create_future()
method = getattr(self.db_plugin_iface, name) method = getattr(self.db_plugin_iface, name)
@ -191,7 +191,7 @@ class AIOBridge(Bridge):
) )
except ValueError as e: except ValueError as e:
if e.args[0].startswith("Unable to guess signature"): if e.args[0].startswith("Unable to guess signature"):
# same hack as for Bridge.__getattribute__ # same hack as for bridge.__getattribute__
log.warning("using hack to work around inspection issue") log.warning("using hack to work around inspection issue")
proxy = self.db_plugin_iface.proxy_object proxy = self.db_plugin_iface.proxy_object
IN_PROGRESS = proxy.INTROSPECT_STATE_INTROSPECT_IN_PROGRESS IN_PROGRESS = proxy.INTROSPECT_STATE_INTROSPECT_IN_PROGRESS
@ -209,12 +209,12 @@ class AIOBridge(Bridge):
raise e raise e
return fut return fut
return getPluginMethod return get_plugin_method
def bridgeConnect(self): def bridge_connect(self):
loop = asyncio.get_running_loop() loop = asyncio.get_running_loop()
fut = loop.create_future() fut = loop.create_future()
super().bridgeConnect( super().bridge_connect(
callback=lambda: loop.call_soon_threadsafe(fut.set_result, None), callback=lambda: loop.call_soon_threadsafe(fut.set_result, None),
errback=lambda e: loop.call_soon_threadsafe(fut.set_exception, e) errback=lambda e: loop.call_soon_threadsafe(fut.set_exception, e)
) )

View file

@ -51,7 +51,7 @@ class EmbeddedConstructor(base_constructor.Constructor):
"debug": "" "debug": ""
if not self.args.debug if not self.args.debug
else 'log.debug ("%s")\n%s' % (completion["name"], 8 * " "), else 'log.debug ("%s")\n%s' % (completion["name"], 8 * " "),
"args_result": self.getArguments(function["sig_in"], name=arg_doc), "args_result": self.get_arguments(function["sig_in"], name=arg_doc),
"args_comma": ", " if function["sig_in"] else "", "args_comma": ", " if function["sig_in"] else "",
} }
) )
@ -96,5 +96,5 @@ class EmbeddedConstructor(base_constructor.Constructor):
def core_completion_signal(self, completion, function, default, arg_doc, async_): def core_completion_signal(self, completion, function, default, arg_doc, async_):
completion.update( completion.update(
{"args_result": self.getArguments(function["sig_in"], name=arg_doc)} {"args_result": self.get_arguments(function["sig_in"], name=arg_doc)}
) )

View file

@ -17,4 +17,4 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from sat.bridge.embedded import Bridge from sat.bridge.embedded import bridge

View file

@ -29,7 +29,7 @@ class _Bridge(object):
self._methods_cbs = {} self._methods_cbs = {}
self._signals_cbs = {"core": {}, "plugin": {}} self._signals_cbs = {"core": {}, "plugin": {}}
def bridgeConnect(self, callback, errback): def bridge_connect(self, callback, errback):
callback() callback()
def register_method(self, name, callback): def register_method(self, name, callback):
@ -85,7 +85,7 @@ class _Bridge(object):
else: else:
cb(*args, **kwargs) cb(*args, **kwargs)
def addMethod(self, name, int_suffix, in_sign, out_sign, method, async_=False, doc={}): def add_method(self, name, int_suffix, in_sign, out_sign, method, async_=False, doc={}):
# FIXME: doc parameter is kept only temporary, the time to remove it from calls # FIXME: doc parameter is kept only temporary, the time to remove it from calls
log.debug("Adding method [{}] to embedded bridge".format(name)) log.debug("Adding method [{}] to embedded bridge".format(name))
self.register_method(name, method) self.register_method(name, method)
@ -97,7 +97,7 @@ class _Bridge(object):
), ),
) )
def addSignal(self, name, int_suffix, signature, doc={}): def add_signal(self, name, int_suffix, signature, doc={}):
setattr( setattr(
self.__class__, self.__class__,
name, name,
@ -116,7 +116,7 @@ class _Bridge(object):
bridge = None bridge = None
def Bridge(): def bridge():
global bridge global bridge
if bridge is None: if bridge is None:
bridge = _Bridge() bridge = _Bridge()

View file

@ -29,7 +29,7 @@ class MediawikiConstructor(base_constructor.Constructor):
self.core_template = "mediawiki_template.tpl" self.core_template = "mediawiki_template.tpl"
self.core_dest = "mediawiki.wiki" self.core_dest = "mediawiki.wiki"
def _addTextDecorations(self, text): def _add_text_decorations(self, text):
"""Add text decorations like coloration or shortcuts""" """Add text decorations like coloration or shortcuts"""
def anchor_link(match): def anchor_link(match):
@ -42,43 +42,43 @@ class MediawikiConstructor(base_constructor.Constructor):
return re.sub(r"\[(\w+)\]", anchor_link, text) return re.sub(r"\[(\w+)\]", anchor_link, text)
def _wikiParameter(self, name, sig_in): def _wiki_parameter(self, name, sig_in):
"""Format parameters with the wiki syntax """Format parameters with the wiki syntax
@param name: name of the function @param name: name of the function
@param sig_in: signature in @param sig_in: signature in
@return: string of the formated parameters""" @return: string of the formated parameters"""
arg_doc = self.getArgumentsDoc(name) arg_doc = self.get_arguments_doc(name)
arg_default = self.getDefault(name) arg_default = self.get_default(name)
args_str = self.getArguments(sig_in) args_str = self.get_arguments(sig_in)
args = args_str.split(", ") if args_str else [] # ugly but it works :) args = args_str.split(", ") if args_str else [] # ugly but it works :)
wiki = [] wiki = []
for i in range(len(args)): for i in range(len(args)):
if i in arg_doc: if i in arg_doc:
name, doc = arg_doc[i] name, doc = arg_doc[i]
doc = "\n:".join(doc.rstrip("\n").split("\n")) doc = "\n:".join(doc.rstrip("\n").split("\n"))
wiki.append("; %s: %s" % (name, self._addTextDecorations(doc))) wiki.append("; %s: %s" % (name, self._add_text_decorations(doc)))
else: else:
wiki.append("; arg_%d: " % i) wiki.append("; arg_%d: " % i)
if i in arg_default: if i in arg_default:
wiki.append(":''DEFAULT: %s''" % arg_default[i]) wiki.append(":''DEFAULT: %s''" % arg_default[i])
return "\n".join(wiki) return "\n".join(wiki)
def _wikiReturn(self, name): def _wiki_return(self, name):
"""Format return doc with the wiki syntax """Format return doc with the wiki syntax
@param name: name of the function @param name: name of the function
""" """
arg_doc = self.getArgumentsDoc(name) arg_doc = self.get_arguments_doc(name)
wiki = [] wiki = []
if "return" in arg_doc: if "return" in arg_doc:
wiki.append("\n|-\n! scope=row | return value\n|") wiki.append("\n|-\n! scope=row | return value\n|")
wiki.append( wiki.append(
"<br />\n".join( "<br />\n".join(
self._addTextDecorations(arg_doc["return"]).rstrip("\n").split("\n") self._add_text_decorations(arg_doc["return"]).rstrip("\n").split("\n")
) )
) )
return "\n".join(wiki) return "\n".join(wiki)
def generateCoreSide(self): def generate_core_side(self):
signals_part = [] signals_part = []
methods_part = [] methods_part = []
sections = self.bridge_template.sections() sections = self.bridge_template.sections()
@ -114,13 +114,13 @@ class MediawikiConstructor(base_constructor.Constructor):
"sig_out": function["sig_out"] or "", "sig_out": function["sig_out"] or "",
"category": function["category"], "category": function["category"],
"name": section, "name": section,
"doc": self.getDoc(section) or "FIXME: No description available", "doc": self.get_doc(section) or "FIXME: No description available",
"async": async_msg if "async" in self.getFlags(section) else "", "async": async_msg if "async" in self.getFlags(section) else "",
"deprecated": deprecated_msg "deprecated": deprecated_msg
if "deprecated" in self.getFlags(section) if "deprecated" in self.getFlags(section)
else "", else "",
"parameters": self._wikiParameter(section, function["sig_in"]), "parameters": self._wiki_parameter(section, function["sig_in"]),
"return": self._wikiReturn(section) "return": self._wiki_return(section)
if function["type"] == "method" if function["type"] == "method"
else "", else "",
} }
@ -148,7 +148,7 @@ class MediawikiConstructor(base_constructor.Constructor):
# at this point, signals_part, and methods_part should be filled, # at this point, signals_part, and methods_part should be filled,
# we just have to place them in the right part of the template # we just have to place them in the right part of the template
core_bridge = [] core_bridge = []
template_path = self.getTemplatePath(self.core_template) template_path = self.get_template_path(self.core_template)
try: try:
with open(template_path) as core_template: with open(template_path) as core_template:
for line in core_template: for line in core_template:
@ -165,4 +165,4 @@ class MediawikiConstructor(base_constructor.Constructor):
sys.exit(1) sys.exit(1)
# now we write to final file # now we write to final file
self.finalWrite(self.core_dest, core_bridge) self.final_write(self.core_dest, core_bridge)

View file

@ -26,7 +26,7 @@ class pbConstructor(base_constructor.Constructor):
CORE_FORMATS = { CORE_FORMATS = {
"signals": """\ "signals": """\
def {name}(self, {args}): def {name}(self, {args}):
{debug}self.sendSignal("{name}", {args_no_def})\n""" {debug}self.send_signal("{name}", {args_no_def})\n"""
} }
FRONTEND_TEMPLATE = "pb_frontend_template.py" FRONTEND_TEMPLATE = "pb_frontend_template.py"
@ -49,7 +49,7 @@ class pbConstructor(base_constructor.Constructor):
} }
def core_completion_signal(self, completion, function, default, arg_doc, async_): def core_completion_signal(self, completion, function, default, arg_doc, async_):
completion["args_no_def"] = self.getArguments(function["sig_in"], name=arg_doc) completion["args_no_def"] = self.get_arguments(function["sig_in"], name=arg_doc)
completion["debug"] = ( completion["debug"] = (
"" ""
if not self.args.debug if not self.args.debug
@ -60,7 +60,7 @@ class pbConstructor(base_constructor.Constructor):
completion.update( completion.update(
{ {
"args_comma": ", " if function["sig_in"] else "", "args_comma": ", " if function["sig_in"] else "",
"args_no_def": self.getArguments(function["sig_in"], name=arg_doc), "args_no_def": self.get_arguments(function["sig_in"], name=arg_doc),
"callback": "callback" "callback": "callback"
if function["sig_out"] if function["sig_out"]
else "lambda __: callback()", else "lambda __: callback()",

Some files were not shown because too many files have changed in this diff Show more