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:
parent
d50412c7f7
commit
6a6f15707a
14 changed files with 9945 additions and 9945 deletions
|
|
@ -74,7 +74,7 @@ class Constructor(object):
|
|||
function[option] = value
|
||||
return function
|
||||
|
||||
def getDefault(self, name):
|
||||
def get_default(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)"""
|
||||
|
|
@ -106,7 +106,7 @@ class Constructor(object):
|
|||
flags.append(option)
|
||||
return flags
|
||||
|
||||
def getArgumentsDoc(self, name):
|
||||
def get_arguments_doc(self, name):
|
||||
"""Return documentation of arguments
|
||||
@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)"""
|
||||
|
|
@ -131,7 +131,7 @@ class Constructor(object):
|
|||
doc_dict[idx] = (value_match.group(1), value_match.group(2))
|
||||
return doc_dict
|
||||
|
||||
def getDoc(self, name):
|
||||
def get_doc(self, name):
|
||||
"""Return documentation of the method
|
||||
@param name: Name of the function to get
|
||||
@return: string documentation, or None"""
|
||||
|
|
@ -139,7 +139,7 @@ class Constructor(object):
|
|||
return self.bridge_template.get(name, "doc")
|
||||
return None
|
||||
|
||||
def argumentsParser(self, signature):
|
||||
def arguments_parser(self, signature):
|
||||
"""Generator which return individual arguments signatures from a global signature"""
|
||||
start = 0
|
||||
i = 0
|
||||
|
|
@ -176,19 +176,19 @@ class Constructor(object):
|
|||
yield signature[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
|
||||
|
||||
@param signature: signature in the short form (using s,a,i,b etc)
|
||||
@param name: dictionary of arguments name like given by getArgumentsDoc
|
||||
@param default: dictionary of default values, like given by getDefault
|
||||
@param name: dictionary of arguments name like given by get_arguments_doc
|
||||
@param default: dictionary of default values, like given by get_default
|
||||
@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")
|
||||
"""
|
||||
idx = 0
|
||||
attr_string = []
|
||||
|
||||
for arg in self.argumentsParser(signature):
|
||||
for arg in self.arguments_parser(signature):
|
||||
attr_string.append(
|
||||
(
|
||||
"str(%(name)s)%(default)s"
|
||||
|
|
@ -206,7 +206,7 @@ class Constructor(object):
|
|||
|
||||
return ", ".join(attr_string)
|
||||
|
||||
def getTemplatePath(self, template_file):
|
||||
def get_template_path(self, template_file):
|
||||
"""return template path corresponding to file name
|
||||
|
||||
@param template_file(str): name of template file
|
||||
|
|
@ -232,12 +232,12 @@ class Constructor(object):
|
|||
def generate(self, side):
|
||||
"""generate bridge
|
||||
|
||||
call generateCoreSide or generateFrontendSide if they exists
|
||||
call generate_core_side or generateFrontendSide if they exists
|
||||
else call generic self._generate method
|
||||
"""
|
||||
try:
|
||||
if side == "core":
|
||||
method = self.generateCoreSide
|
||||
method = self.generate_core_side
|
||||
elif side == "frontend":
|
||||
if not self.FRONTEND_ACTIVATE:
|
||||
print("This constructor only handle core, please use core side")
|
||||
|
|
@ -272,8 +272,8 @@ class Constructor(object):
|
|||
for section in sections:
|
||||
function = self.getValues(section)
|
||||
print(("Adding %s %s" % (section, function["type"])))
|
||||
default = self.getDefault(section)
|
||||
arg_doc = self.getArgumentsDoc(section)
|
||||
default = self.get_default(section)
|
||||
arg_doc = self.get_arguments_doc(section)
|
||||
async_ = "async" in self.getFlags(section)
|
||||
completion = {
|
||||
"sig_in": function["sig_in"] or "",
|
||||
|
|
@ -281,10 +281,10 @@ class Constructor(object):
|
|||
"category": "plugin" if function["category"] == "plugin" else "core",
|
||||
"name": section,
|
||||
# arguments with default values
|
||||
"args": self.getArguments(
|
||||
"args": self.get_arguments(
|
||||
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(
|
||||
|
|
@ -305,7 +305,7 @@ class Constructor(object):
|
|||
for env, v in os.environ.items()
|
||||
if env.startswith(C.ENV_OVERRIDE)
|
||||
}
|
||||
template_path = self.getTemplatePath(TEMPLATE)
|
||||
template_path = self.get_template_path(TEMPLATE)
|
||||
try:
|
||||
with open(template_path) as template:
|
||||
for line in template:
|
||||
|
|
@ -332,9 +332,9 @@ class Constructor(object):
|
|||
sys.exit(1)
|
||||
|
||||
# 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
|
||||
|
||||
@param filename: name of the file to generate
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ __version__ = C.APP_VERSION
|
|||
|
||||
|
||||
class BridgeConstructor(object):
|
||||
def importConstructors(self):
|
||||
def import_constructors(self):
|
||||
constructors_dir = os.path.dirname(constructors.__file__)
|
||||
self.protocoles = {}
|
||||
for dir_ in os.listdir(constructors_dir):
|
||||
|
|
@ -120,7 +120,7 @@ class BridgeConstructor(object):
|
|||
return parser.parse_args()
|
||||
|
||||
def go(self):
|
||||
self.importConstructors()
|
||||
self.import_constructors()
|
||||
args = self.parse_args()
|
||||
template_parser = Parser()
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ sig_in=s
|
|||
doc=Connection is finished or lost
|
||||
doc_param_0=%(doc_profile)s
|
||||
|
||||
[newContact]
|
||||
[contact_new]
|
||||
type=signal
|
||||
category=core
|
||||
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_3=%(doc_profile)s
|
||||
|
||||
[messageNew]
|
||||
[message_new]
|
||||
type=signal
|
||||
category=core
|
||||
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
|
||||
doc_param_8=%(doc_profile)s
|
||||
|
||||
[messageEncryptionStarted]
|
||||
[message_encryption_started]
|
||||
type=signal
|
||||
category=core
|
||||
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
|
||||
doc_param_2=%(doc_profile_key)s
|
||||
|
||||
[messageEncryptionStopped]
|
||||
[message_encryption_stopped]
|
||||
type=signal
|
||||
category=core
|
||||
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
|
||||
doc_param_2=%(doc_profile_key)s
|
||||
|
||||
[presenceUpdate]
|
||||
[presence_update]
|
||||
type=signal
|
||||
category=core
|
||||
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_2=%(doc_profile)s
|
||||
|
||||
[paramUpdate]
|
||||
[param_update]
|
||||
type=signal
|
||||
category=core
|
||||
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_3=%(doc_profile)s
|
||||
|
||||
[contactDeleted]
|
||||
[contact_deleted]
|
||||
type=signal
|
||||
category=core
|
||||
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_1=%(doc_profile)s
|
||||
|
||||
[actionNew]
|
||||
[action_new]
|
||||
type=signal
|
||||
category=core
|
||||
sig_in=a{ss}sis
|
||||
|
|
@ -137,7 +137,7 @@ doc_param_1=id: action id
|
|||
doc_param_2=%(doc_security_limit)s
|
||||
doc_param_3=%(doc_profile)s
|
||||
|
||||
[entityDataUpdated]
|
||||
[entity_data_updated]
|
||||
type=signal
|
||||
category=core
|
||||
sig_in=ssss
|
||||
|
|
@ -147,7 +147,7 @@ doc_param_1=name: Name of the updated value
|
|||
doc_param_2=value: New value
|
||||
doc_param_3=%(doc_profile)s
|
||||
|
||||
[progressStarted]
|
||||
[progress_started]
|
||||
type=signal
|
||||
category=core
|
||||
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
|
||||
doc_param_2=%(doc_profile)s
|
||||
|
||||
[progressFinished]
|
||||
[progress_finished]
|
||||
type=signal
|
||||
category=core
|
||||
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_algo: alrorithm used to compute hash
|
||||
- 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)
|
||||
doc_param_2=%(doc_profile)s
|
||||
|
||||
[progressError]
|
||||
[progress_error]
|
||||
type=signal
|
||||
category=core
|
||||
sig_in=sss
|
||||
|
|
@ -194,7 +194,7 @@ doc_param_2=%(doc_profile)s
|
|||
|
||||
;methods
|
||||
|
||||
[getReady]
|
||||
[ready_get]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
@ -202,14 +202,14 @@ sig_in=
|
|||
sig_out=
|
||||
doc=Return when backend is initialised
|
||||
|
||||
[getVersion]
|
||||
[version_get]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=
|
||||
sig_out=s
|
||||
doc=Get "Salut à Toi" full version
|
||||
|
||||
[getFeatures]
|
||||
[features_get]
|
||||
type=method
|
||||
category=core
|
||||
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
|
||||
async=
|
||||
|
||||
[profileNameGet]
|
||||
[profile_name_get]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=s
|
||||
|
|
@ -231,7 +231,7 @@ doc=Get real profile name from profile key
|
|||
doc_param_0=%(doc_profile_key)s
|
||||
doc_return=Real profile name
|
||||
|
||||
[profilesListGet]
|
||||
[profiles_list_get]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=bb
|
||||
|
|
@ -242,7 +242,7 @@ doc_param_0=clients: get clients profiles
|
|||
doc_param_1=components: get components profiles
|
||||
doc=Get list of profiles
|
||||
|
||||
[profileSetDefault]
|
||||
[profile_set_default]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=s
|
||||
|
|
@ -250,7 +250,7 @@ sig_out=
|
|||
doc_param_0=%(doc_profile)s
|
||||
doc=Set default profile
|
||||
|
||||
[getEntityData]
|
||||
[entity_data_get]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=sass
|
||||
|
|
@ -262,7 +262,7 @@ doc_param_2=%(doc_profile)s
|
|||
doc_return=dictionary of asked key,
|
||||
if key doesn't exist, the resulting dictionary will not have the key
|
||||
|
||||
[getEntitiesData]
|
||||
[entities_data_get]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=asass
|
||||
|
|
@ -275,7 +275,7 @@ doc_return=dictionary with jids as keys and dictionary of asked key as values
|
|||
values are serialised
|
||||
if key doesn't exist for a jid, the resulting dictionary will not have it
|
||||
|
||||
[profileCreate]
|
||||
[profile_create]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
@ -293,7 +293,7 @@ errback is called with error constant as parameter:
|
|||
- CancelError: profile creation canceled
|
||||
- NotFound: component entry point is not available
|
||||
|
||||
[asyncDeleteProfile]
|
||||
[profile_delete_async]
|
||||
async=
|
||||
type=method
|
||||
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)
|
||||
- failure if the profile authentication failed
|
||||
|
||||
[profileStartSession]
|
||||
[profile_start_session]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
@ -340,7 +340,7 @@ doc_return=D(bool):
|
|||
- True if the profile session was already started
|
||||
- False else
|
||||
|
||||
[profileIsSessionStarted]
|
||||
[profile_is_session_started]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=s
|
||||
|
|
@ -359,7 +359,7 @@ param_0_default="@DEFAULT@"
|
|||
doc=Disconnect a profile
|
||||
doc_param_0=%(doc_profile_key)s
|
||||
|
||||
[isConnected]
|
||||
[is_connected]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=s
|
||||
|
|
@ -368,7 +368,7 @@ param_0_default="@DEFAULT@"
|
|||
doc=Tell if a profile is connected
|
||||
doc_param_0=%(doc_profile_key)s
|
||||
|
||||
[contactGet]
|
||||
[contact_get]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
@ -378,10 +378,10 @@ param_1_default="@DEFAULT@"
|
|||
doc=Return informations in roster about a contact
|
||||
doc_param_1=%(doc_profile_key)s
|
||||
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
|
||||
|
||||
[getContacts]
|
||||
[contacts_get]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
@ -392,10 +392,10 @@ doc=Return information about all contacts (the roster)
|
|||
doc_param_0=%(doc_profile_key)s
|
||||
doc_return=array of tuples with the following values:
|
||||
- JID of the contact
|
||||
- list of attributes as in [newContact]
|
||||
- list of attributes as in [contact_new]
|
||||
- groups where the contact is
|
||||
|
||||
[getContactsFromGroup]
|
||||
[contacts_get_from_group]
|
||||
type=method
|
||||
category=core
|
||||
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_return=array of jids
|
||||
|
||||
[getMainResource]
|
||||
[main_resource_get]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=ss
|
||||
|
|
@ -417,7 +417,7 @@ doc_param_0=contact_jid: jid of the contact
|
|||
doc_param_1=%(doc_profile_key)s
|
||||
doc_return=the resource connected of the contact with highest priority, or ""
|
||||
|
||||
[getPresenceStatuses]
|
||||
[presence_statuses_get]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=s
|
||||
|
|
@ -426,9 +426,9 @@ param_0_default="@DEFAULT@"
|
|||
doc=Return presence information 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 [presence_update]
|
||||
|
||||
[getWaitingSub]
|
||||
[sub_waiting_get]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=s
|
||||
|
|
@ -438,7 +438,7 @@ doc=Get subscription requests in queue
|
|||
doc_param_0=%(doc_profile_key)s
|
||||
doc_return=Dict where contact JID is the key, and value is the subscription type
|
||||
|
||||
[messageSend]
|
||||
[message_send]
|
||||
async=
|
||||
type=method
|
||||
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_5=%(doc_profile_key)s
|
||||
|
||||
[messageEncryptionStart]
|
||||
[message_encryption_start]
|
||||
async=
|
||||
type=method
|
||||
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
|
||||
doc_param_3=%(doc_profile_key)s
|
||||
|
||||
[messageEncryptionStop]
|
||||
[message_encryption_stop]
|
||||
async=
|
||||
type=method
|
||||
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_1=%(doc_profile_key)s
|
||||
|
||||
[messageEncryptionGet]
|
||||
[message_encryption_get]
|
||||
type=method
|
||||
category=core
|
||||
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:
|
||||
- directed_devices: list or resource where session is encrypted
|
||||
|
||||
[encryptionNamespaceGet]
|
||||
[encryption_namespace_get]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=s
|
||||
sig_out=s
|
||||
doc=Get algorithm namespace from its name
|
||||
|
||||
[encryptionPluginsGet]
|
||||
[encryption_plugins_get]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=
|
||||
sig_out=s
|
||||
doc=Retrieve registered plugins for encryption
|
||||
|
||||
[encryptionTrustUIGet]
|
||||
[encryption_trust_ui_get]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
@ -525,7 +525,7 @@ doc_param_1=namespace: namespace of the algorithm to manage
|
|||
doc_param_2=%(doc_profile_key)s
|
||||
doc_return=(XMLUI) UI of the trust management
|
||||
|
||||
[setPresence]
|
||||
[presence_set]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=ssa{ss}s
|
||||
|
|
@ -536,8 +536,8 @@ param_2_default={}
|
|||
param_3_default="@DEFAULT@"
|
||||
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_1=show: as for [presenceUpdate]
|
||||
doc_param_2=statuses: as for [presenceUpdate]
|
||||
doc_param_1=show: as for [presence_update]
|
||||
doc_param_2=statuses: as for [presence_update]
|
||||
doc_param_3=%(doc_profile_key)s
|
||||
|
||||
[subscription]
|
||||
|
|
@ -551,7 +551,7 @@ doc_param_0=sub_type: as for [subscribe]
|
|||
doc_param_1=entity: as for [subscribe]
|
||||
doc_param_2=%(doc_profile_key)s
|
||||
|
||||
[getConfig]
|
||||
[config_get]
|
||||
type=method
|
||||
category=core
|
||||
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_1=name: name of the option
|
||||
|
||||
[setParam]
|
||||
[param_set]
|
||||
type=method
|
||||
category=core
|
||||
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_4=%(doc_profile_key)s
|
||||
|
||||
[getParamA]
|
||||
[param_get_a]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=ssss
|
||||
|
|
@ -582,12 +582,12 @@ sig_out=s
|
|||
param_2_default="value"
|
||||
param_3_default="@DEFAULT@"
|
||||
doc=Helper method to get a parameter's attribute *when profile is connected*
|
||||
doc_param_0=name: as for [setParam]
|
||||
doc_param_1=category: as for [setParam]
|
||||
doc_param_0=name: as for [param_set]
|
||||
doc_param_1=category: as for [param_set]
|
||||
doc_param_2=attribute: Name of the attribute
|
||||
doc_param_3=%(doc_profile_key)s
|
||||
|
||||
[privateDataGet]
|
||||
[private_data_get]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
@ -599,7 +599,7 @@ doc_param_1=key: key of the data to set
|
|||
doc_param_2=%(doc_profile_key)s
|
||||
doc_return=serialised data
|
||||
|
||||
[privateDataSet]
|
||||
[private_data_set]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
@ -611,7 +611,7 @@ doc_param_1=key: key of the data to set
|
|||
doc_param_2=data: serialised data
|
||||
doc_param_3=%(doc_profile_key)s
|
||||
|
||||
[privateDataDelete]
|
||||
[private_data_delete]
|
||||
async=
|
||||
type=method
|
||||
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_3=%(doc_profile_key)s
|
||||
|
||||
[asyncGetParamA]
|
||||
[param_get_a_async]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
@ -632,13 +632,13 @@ param_2_default="value"
|
|||
param_3_default=-1
|
||||
param_4_default="@DEFAULT@"
|
||||
doc=Helper method to get a parameter's attribute
|
||||
doc_param_0=name: as for [setParam]
|
||||
doc_param_1=category: as for [setParam]
|
||||
doc_param_0=name: as for [param_set]
|
||||
doc_param_1=category: as for [param_set]
|
||||
doc_param_2=attribute: Name of the attribute
|
||||
doc_param_3=%(doc_security_limit)s
|
||||
doc_param_4=%(doc_profile_key)s
|
||||
|
||||
[asyncGetParamsValuesFromCategory]
|
||||
[params_values_from_category_get_async]
|
||||
async=
|
||||
type=method
|
||||
category=code
|
||||
|
|
@ -649,13 +649,13 @@ param_2_default=""
|
|||
param_3_default=""
|
||||
param_4_default="@DEFAULT@"
|
||||
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_2=app: name of the frontend requesting the parameters, or '' to get all parameters
|
||||
doc_param_3=extra: extra options/filters
|
||||
doc_param_4=%(doc_profile_key)s
|
||||
|
||||
[getParamsUI]
|
||||
[param_ui_get]
|
||||
async=
|
||||
type=method
|
||||
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_3=%(doc_profile_key)s
|
||||
|
||||
[getParamsCategories]
|
||||
[params_categories_get]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=
|
||||
|
|
@ -679,7 +679,7 @@ sig_out=as
|
|||
doc=Get all categories currently existing in parameters
|
||||
doc_return=list of categories
|
||||
|
||||
[paramsRegisterApp]
|
||||
[params_register_app]
|
||||
type=method
|
||||
category=core
|
||||
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_2=app: name of the frontend registering the parameters
|
||||
|
||||
[historyGet]
|
||||
[history_get]
|
||||
async=
|
||||
type=method
|
||||
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
|
||||
- before_uid: check only message received before message with given uid
|
||||
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
|
||||
category=core
|
||||
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_1=%(doc_profile_key)s
|
||||
|
||||
[updateContact]
|
||||
[contact_update]
|
||||
type=method
|
||||
category=core
|
||||
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_3=%(doc_profile_key)s
|
||||
|
||||
[delContact]
|
||||
[contact_del]
|
||||
async=
|
||||
type=method
|
||||
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_1=%(doc_profile_key)s
|
||||
|
||||
[rosterResync]
|
||||
[roster_resync]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
@ -757,7 +757,7 @@ param_0_default="@DEFAULT@"
|
|||
doc=Do a full resynchronisation of roster with server
|
||||
doc_param_0=%(doc_profile_key)s
|
||||
|
||||
[launchAction]
|
||||
[action_launch]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
@ -771,7 +771,7 @@ doc_param_2=%(doc_profile_key)s
|
|||
doc_return=dict where key can be:
|
||||
- xmlui: a XMLUI need to be displayed
|
||||
|
||||
[actionsGet]
|
||||
[actions_get]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=s
|
||||
|
|
@ -779,9 +779,9 @@ sig_out=a(a{ss}si)
|
|||
param_0_default="@DEFAULT@"
|
||||
doc=Get all not yet answered actions
|
||||
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
|
||||
category=core
|
||||
sig_in=ss
|
||||
|
|
@ -794,7 +794,7 @@ doc_return=dict with progress informations:
|
|||
- size: end position (optional if not known)
|
||||
other metadata may be present
|
||||
|
||||
[progressGetAllMetadata]
|
||||
[progress_get_all_metadata]
|
||||
type=method
|
||||
category=core
|
||||
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_return= a dict which map profile to progress_dict
|
||||
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
|
||||
category=core
|
||||
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_return= a dict which map profile to progress_dict
|
||||
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
|
||||
category=core
|
||||
sig_in=si
|
||||
|
|
@ -832,7 +832,7 @@ doc_return=list of tuple with the following value:
|
|||
- menu_path_i18n: translated path of the menu
|
||||
- extra: extra data, like icon name
|
||||
|
||||
[menuLaunch]
|
||||
[menu_launch]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
@ -847,7 +847,7 @@ doc_param_4=%(doc_profile_key)s
|
|||
doc_return=dict where key can be:
|
||||
- xmlui: a XMLUI need to be displayed
|
||||
|
||||
[menuHelpGet]
|
||||
[menu_help_get]
|
||||
type=method
|
||||
category=core
|
||||
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_return=Translated help string
|
||||
|
||||
[discoInfos]
|
||||
[disco_infos]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
@ -884,7 +884,7 @@ doc_return=discovery data:
|
|||
* desc
|
||||
- list of values
|
||||
|
||||
[discoItems]
|
||||
[disco_items]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
@ -900,7 +900,7 @@ doc_param_2=use_cache: use cached data if available
|
|||
doc_param_3=%(doc_profile_key)s
|
||||
doc_return=array of tuple (entity, node identifier, name)
|
||||
|
||||
[discoFindByFeatures]
|
||||
[disco_find_by_features]
|
||||
async=
|
||||
type=method
|
||||
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)
|
||||
- roster entities
|
||||
|
||||
[saveParamsTemplate]
|
||||
[params_template_save]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=s
|
||||
|
|
@ -936,7 +936,7 @@ doc=Save parameters template to xml file
|
|||
doc_param_0=filename: output filename
|
||||
doc_return=boolean (True in case of success)
|
||||
|
||||
[loadParamsTemplate]
|
||||
[params_template_load]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=s
|
||||
|
|
@ -945,7 +945,7 @@ doc=Load parameters template from xml file
|
|||
doc_param_0=filename: input filename
|
||||
doc_return=boolean (True in case of success)
|
||||
|
||||
[sessionInfosGet]
|
||||
[session_infos_get]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
@ -957,7 +957,7 @@ doc_return=session informations, with at least the following keys:
|
|||
jid: current full jid
|
||||
started: date of creation of the session (Epoch time)
|
||||
|
||||
[devicesInfosGet]
|
||||
[devices_infos_get]
|
||||
async=
|
||||
type=method
|
||||
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:
|
||||
resource: device resource
|
||||
|
||||
[namespacesGet]
|
||||
[namespaces_get]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=
|
||||
|
|
@ -978,7 +978,7 @@ sig_out=a{ss}
|
|||
doc=Get a dict to short name => whole namespaces
|
||||
doc_return=namespaces mapping
|
||||
|
||||
[imageCheck]
|
||||
[image_check]
|
||||
type=method
|
||||
category=core
|
||||
sig_in=s
|
||||
|
|
@ -986,7 +986,7 @@ sig_out=s
|
|||
doc=Analyze an image a return a report
|
||||
doc_return=serialized report
|
||||
|
||||
[imageResize]
|
||||
[image_resize]
|
||||
async=
|
||||
type=method
|
||||
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
|
||||
the image must be deleted once not needed anymore
|
||||
|
||||
[imageGeneratePreview]
|
||||
[image_generate_preview]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
@ -1010,7 +1010,7 @@ doc_param_0=image_path: path of the original image
|
|||
doc_param_1=%(doc_profile_key)s
|
||||
doc_return=path to the preview in cache
|
||||
|
||||
[imageConvert]
|
||||
[image_convert]
|
||||
async=
|
||||
type=method
|
||||
category=core
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ class DbusXmlConstructor(base_constructor.Constructor):
|
|||
"a{sa{s(sia{ss})}}": "PresenceStatusT",
|
||||
}
|
||||
|
||||
def generateCoreSide(self):
|
||||
def generate_core_side(self):
|
||||
try:
|
||||
doc = minidom.parse(self.getTemplatePath(self.template))
|
||||
doc = minidom.parse(self.get_template_path(self.template))
|
||||
interface_elt = doc.getElementsByTagName("interface")[0]
|
||||
except IOError:
|
||||
print("Can't access template")
|
||||
|
|
@ -60,8 +60,8 @@ class DbusXmlConstructor(base_constructor.Constructor):
|
|||
new_elt.setAttribute("name", section)
|
||||
|
||||
idx = 0
|
||||
args_doc = self.getArgumentsDoc(section)
|
||||
for arg in self.argumentsParser(function["sig_in"] or ""):
|
||||
args_doc = self.get_arguments_doc(section)
|
||||
for arg in self.arguments_parser(function["sig_in"] or ""):
|
||||
arg_elt = doc.createElement("arg")
|
||||
arg_elt.setAttribute(
|
||||
"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)
|
||||
|
||||
# now we write to final file
|
||||
self.finalWrite(self.core_dest, [doc.toprettyxml()])
|
||||
self.final_write(self.core_dest, [doc.toprettyxml()])
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class DbusConstructor(base_constructor.Constructor):
|
|||
"debug": ""
|
||||
if not self.args.debug
|
||||
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_comma": ", " if function["sig_in"] else "",
|
||||
"error_handler": """if callback is None:
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ from txdbus.interface import DBusInterface, Method, Signal
|
|||
log = getLogger(__name__)
|
||||
|
||||
# Interface prefix
|
||||
const_INT_PREFIX = config.getConfig(
|
||||
config.parseMainConf(),
|
||||
const_INT_PREFIX = config.config_get(
|
||||
config.parse_main_conf(),
|
||||
"",
|
||||
"bridge_dbus_int_prefix",
|
||||
"org.libervia.Libervia")
|
||||
|
|
@ -118,13 +118,13 @@ class DBusObject(objects.DBusObject):
|
|||
|
||||
##METHODS_PART##
|
||||
|
||||
class Bridge:
|
||||
class bridge:
|
||||
|
||||
def __init__(self):
|
||||
log.info("Init DBus...")
|
||||
self._obj = DBusObject(const_OBJ_PATH)
|
||||
|
||||
async def postInit(self):
|
||||
async def post_init(self):
|
||||
try:
|
||||
conn = await client.connect(reactor)
|
||||
except error.DBusException as e:
|
||||
|
|
@ -145,13 +145,13 @@ class Bridge:
|
|||
log.debug(f"registering DBus bridge method [{name}]")
|
||||
self._obj.register_method(name, callback)
|
||||
|
||||
def emitSignal(self, name, *args):
|
||||
def emit_signal(self, name, *args):
|
||||
self._obj.emitSignal(name, *args)
|
||||
|
||||
def addMethod(
|
||||
def add_method(
|
||||
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
|
||||
log.debug(f"Adding method {name!r} to D-Bus bridge")
|
||||
self._obj.plugin_iface.addMethod(
|
||||
|
|
@ -164,8 +164,8 @@ class Bridge:
|
|||
setattr(self._obj, f"dbus_{name}", MethodType(caller, self._obj))
|
||||
self.register_method(name, method)
|
||||
|
||||
def addSignal(self, name, int_suffix, signature, doc={}):
|
||||
"""Dynamically add a signal to D-Bus Bridge"""
|
||||
def add_signal(self, name, int_suffix, signature, doc={}):
|
||||
"""Dynamically add a signal to D-Bus bridge"""
|
||||
log.debug(f"Adding signal {name!r} to D-Bus bridge")
|
||||
self._obj.plugin_iface.addSignal(Signal(name, signature))
|
||||
setattr(Bridge, name, partialmethod(Bridge.emitSignal, name))
|
||||
setattr(bridge, name, partialmethod(bridge.emit_signal, name))
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ log = getLogger(__name__)
|
|||
|
||||
|
||||
# Interface prefix
|
||||
const_INT_PREFIX = config.getConfig(
|
||||
config.parseMainConf(),
|
||||
const_INT_PREFIX = config.config_get(
|
||||
config.parse_main_conf(),
|
||||
"",
|
||||
"bridge_dbus_int_prefix",
|
||||
"org.libervia.Libervia")
|
||||
|
|
@ -66,9 +66,9 @@ def dbus_to_bridge_exception(dbus_e):
|
|||
return BridgeException(name, message, condition)
|
||||
|
||||
|
||||
class Bridge:
|
||||
class bridge:
|
||||
|
||||
def bridgeConnect(self, callback, errback):
|
||||
def bridge_connect(self, callback, errback):
|
||||
try:
|
||||
self.sessions_bus = dbus.SessionBus()
|
||||
self.db_object = self.sessions_bus.get_object(const_INT_PREFIX,
|
||||
|
|
@ -105,7 +105,7 @@ class Bridge:
|
|||
except AttributeError:
|
||||
# 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:
|
||||
# - if we have the 'callback' and 'errback' keyword arguments
|
||||
# - 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)
|
||||
raise e
|
||||
|
||||
return getPluginMethod
|
||||
return get_plugin_method
|
||||
|
||||
##METHODS_PART##
|
||||
|
||||
class AIOBridge(Bridge):
|
||||
class AIOBridge(bridge):
|
||||
|
||||
def register_signal(self, functionName, handler, iface="core"):
|
||||
loop = asyncio.get_running_loop()
|
||||
|
|
@ -173,7 +173,7 @@ class AIOBridge(Bridge):
|
|||
return object.__getattribute__(self, name)
|
||||
except AttributeError:
|
||||
# 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()
|
||||
fut = loop.create_future()
|
||||
method = getattr(self.db_plugin_iface, name)
|
||||
|
|
@ -191,7 +191,7 @@ class AIOBridge(Bridge):
|
|||
)
|
||||
except ValueError as e:
|
||||
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")
|
||||
proxy = self.db_plugin_iface.proxy_object
|
||||
IN_PROGRESS = proxy.INTROSPECT_STATE_INTROSPECT_IN_PROGRESS
|
||||
|
|
@ -209,12 +209,12 @@ class AIOBridge(Bridge):
|
|||
raise e
|
||||
return fut
|
||||
|
||||
return getPluginMethod
|
||||
return get_plugin_method
|
||||
|
||||
def bridgeConnect(self):
|
||||
def bridge_connect(self):
|
||||
loop = asyncio.get_running_loop()
|
||||
fut = loop.create_future()
|
||||
super().bridgeConnect(
|
||||
super().bridge_connect(
|
||||
callback=lambda: loop.call_soon_threadsafe(fut.set_result, None),
|
||||
errback=lambda e: loop.call_soon_threadsafe(fut.set_exception, e)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class EmbeddedConstructor(base_constructor.Constructor):
|
|||
"debug": ""
|
||||
if not self.args.debug
|
||||
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 "",
|
||||
}
|
||||
)
|
||||
|
|
@ -96,5 +96,5 @@ class EmbeddedConstructor(base_constructor.Constructor):
|
|||
|
||||
def core_completion_signal(self, completion, function, default, arg_doc, async_):
|
||||
completion.update(
|
||||
{"args_result": self.getArguments(function["sig_in"], name=arg_doc)}
|
||||
{"args_result": self.get_arguments(function["sig_in"], name=arg_doc)}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -17,4 +17,4 @@
|
|||
# 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/>.
|
||||
|
||||
from sat.bridge.embedded import Bridge
|
||||
from sat.bridge.embedded import bridge
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class _Bridge(object):
|
|||
self._methods_cbs = {}
|
||||
self._signals_cbs = {"core": {}, "plugin": {}}
|
||||
|
||||
def bridgeConnect(self, callback, errback):
|
||||
def bridge_connect(self, callback, errback):
|
||||
callback()
|
||||
|
||||
def register_method(self, name, callback):
|
||||
|
|
@ -85,7 +85,7 @@ class _Bridge(object):
|
|||
else:
|
||||
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
|
||||
log.debug("Adding method [{}] to embedded bridge".format(name))
|
||||
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(
|
||||
self.__class__,
|
||||
name,
|
||||
|
|
@ -116,7 +116,7 @@ class _Bridge(object):
|
|||
bridge = None
|
||||
|
||||
|
||||
def Bridge():
|
||||
def bridge():
|
||||
global bridge
|
||||
if bridge is None:
|
||||
bridge = _Bridge()
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class MediawikiConstructor(base_constructor.Constructor):
|
|||
self.core_template = "mediawiki_template.tpl"
|
||||
self.core_dest = "mediawiki.wiki"
|
||||
|
||||
def _addTextDecorations(self, text):
|
||||
def _add_text_decorations(self, text):
|
||||
"""Add text decorations like coloration or shortcuts"""
|
||||
|
||||
def anchor_link(match):
|
||||
|
|
@ -42,43 +42,43 @@ class MediawikiConstructor(base_constructor.Constructor):
|
|||
|
||||
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
|
||||
@param name: name of the function
|
||||
@param sig_in: signature in
|
||||
@return: string of the formated parameters"""
|
||||
arg_doc = self.getArgumentsDoc(name)
|
||||
arg_default = self.getDefault(name)
|
||||
args_str = self.getArguments(sig_in)
|
||||
arg_doc = self.get_arguments_doc(name)
|
||||
arg_default = self.get_default(name)
|
||||
args_str = self.get_arguments(sig_in)
|
||||
args = args_str.split(", ") if args_str else [] # ugly but it works :)
|
||||
wiki = []
|
||||
for i in range(len(args)):
|
||||
if i in arg_doc:
|
||||
name, doc = arg_doc[i]
|
||||
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:
|
||||
wiki.append("; arg_%d: " % i)
|
||||
if i in arg_default:
|
||||
wiki.append(":''DEFAULT: %s''" % arg_default[i])
|
||||
return "\n".join(wiki)
|
||||
|
||||
def _wikiReturn(self, name):
|
||||
def _wiki_return(self, name):
|
||||
"""Format return doc with the wiki syntax
|
||||
@param name: name of the function
|
||||
"""
|
||||
arg_doc = self.getArgumentsDoc(name)
|
||||
arg_doc = self.get_arguments_doc(name)
|
||||
wiki = []
|
||||
if "return" in arg_doc:
|
||||
wiki.append("\n|-\n! scope=row | return value\n|")
|
||||
wiki.append(
|
||||
"<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)
|
||||
|
||||
def generateCoreSide(self):
|
||||
def generate_core_side(self):
|
||||
signals_part = []
|
||||
methods_part = []
|
||||
sections = self.bridge_template.sections()
|
||||
|
|
@ -114,13 +114,13 @@ class MediawikiConstructor(base_constructor.Constructor):
|
|||
"sig_out": function["sig_out"] or "",
|
||||
"category": function["category"],
|
||||
"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 "",
|
||||
"deprecated": deprecated_msg
|
||||
if "deprecated" in self.getFlags(section)
|
||||
else "",
|
||||
"parameters": self._wikiParameter(section, function["sig_in"]),
|
||||
"return": self._wikiReturn(section)
|
||||
"parameters": self._wiki_parameter(section, function["sig_in"]),
|
||||
"return": self._wiki_return(section)
|
||||
if function["type"] == "method"
|
||||
else "",
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ class MediawikiConstructor(base_constructor.Constructor):
|
|||
# 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 = []
|
||||
template_path = self.getTemplatePath(self.core_template)
|
||||
template_path = self.get_template_path(self.core_template)
|
||||
try:
|
||||
with open(template_path) as core_template:
|
||||
for line in core_template:
|
||||
|
|
@ -165,4 +165,4 @@ class MediawikiConstructor(base_constructor.Constructor):
|
|||
sys.exit(1)
|
||||
|
||||
# now we write to final file
|
||||
self.finalWrite(self.core_dest, core_bridge)
|
||||
self.final_write(self.core_dest, core_bridge)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class pbConstructor(base_constructor.Constructor):
|
|||
CORE_FORMATS = {
|
||||
"signals": """\
|
||||
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"
|
||||
|
|
@ -49,7 +49,7 @@ class pbConstructor(base_constructor.Constructor):
|
|||
}
|
||||
|
||||
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"] = (
|
||||
""
|
||||
if not self.args.debug
|
||||
|
|
@ -60,7 +60,7 @@ class pbConstructor(base_constructor.Constructor):
|
|||
completion.update(
|
||||
{
|
||||
"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"
|
||||
if function["sig_out"]
|
||||
else "lambda __: callback()",
|
||||
|
|
|
|||
|
|
@ -55,17 +55,17 @@ class PBRoot(pb.Root):
|
|||
def __init__(self):
|
||||
self.signals_handlers = []
|
||||
|
||||
def remote_initBridge(self, signals_handler):
|
||||
def remote_init_bridge(self, signals_handler):
|
||||
self.signals_handlers.append(HandlerWrapper(signals_handler))
|
||||
log.info("registered signal handler")
|
||||
|
||||
def sendSignalEb(self, failure_, signal_name):
|
||||
def send_signal_eb(self, failure_, signal_name):
|
||||
if not failure_.check(pb.PBConnectionLost):
|
||||
log.error(
|
||||
f"Error while sending signal {signal_name}: {failure_}",
|
||||
)
|
||||
|
||||
def sendSignal(self, name, args, kwargs):
|
||||
def send_signal(self, name, args, kwargs):
|
||||
to_remove = []
|
||||
for wrapper in self.signals_handlers:
|
||||
handler = wrapper.handler
|
||||
|
|
@ -74,13 +74,13 @@ class PBRoot(pb.Root):
|
|||
except pb.DeadReferenceError:
|
||||
to_remove.append(wrapper)
|
||||
else:
|
||||
d.addErrback(self.sendSignalEb, name)
|
||||
d.addErrback(self.send_signal_eb, name)
|
||||
if to_remove:
|
||||
for wrapper in to_remove:
|
||||
log.debug("Removing signal handler for dead frontend")
|
||||
self.signals_handlers.remove(wrapper)
|
||||
|
||||
def _bridgeDeactivateSignals(self):
|
||||
def _bridge_deactivate_signals(self):
|
||||
if hasattr(self, "signals_paused"):
|
||||
log.warning("bridge signals already deactivated")
|
||||
if self.signals_handler:
|
||||
|
|
@ -90,7 +90,7 @@ class PBRoot(pb.Root):
|
|||
self.signals_handlers = []
|
||||
log.debug("bridge signals have been deactivated")
|
||||
|
||||
def _bridgeReactivateSignals(self):
|
||||
def _bridge_reactivate_signals(self):
|
||||
try:
|
||||
self.signals_handlers = self.signals_paused
|
||||
except AttributeError:
|
||||
|
|
@ -102,31 +102,31 @@ class PBRoot(pb.Root):
|
|||
##METHODS_PART##
|
||||
|
||||
|
||||
class Bridge(object):
|
||||
class bridge(object):
|
||||
def __init__(self):
|
||||
log.info("Init Perspective Broker...")
|
||||
self.root = PBRoot()
|
||||
conf = config.parseMainConf()
|
||||
getConf = partial(config.getConf, conf, "bridge_pb", "")
|
||||
conn_type = getConf("connection_type", "unix_socket")
|
||||
conf = config.parse_main_conf()
|
||||
get_conf = partial(config.get_conf, conf, "bridge_pb", "")
|
||||
conn_type = get_conf("connection_type", "unix_socket")
|
||||
if conn_type == "unix_socket":
|
||||
local_dir = Path(config.getConfig(conf, "", "local_dir")).resolve()
|
||||
local_dir = Path(config.config_get(conf, "", "local_dir")).resolve()
|
||||
socket_path = local_dir / "bridge_pb"
|
||||
log.info(f"using UNIX Socket at {socket_path}")
|
||||
reactor.listenUNIX(
|
||||
str(socket_path), pb.PBServerFactory(self.root), mode=0o600
|
||||
)
|
||||
elif conn_type == "socket":
|
||||
port = int(getConf("port", 8789))
|
||||
port = int(get_conf("port", 8789))
|
||||
log.info(f"using TCP Socket at port {port}")
|
||||
reactor.listenTCP(port, pb.PBServerFactory(self.root))
|
||||
else:
|
||||
raise ValueError(f"Unknown pb connection type: {conn_type!r}")
|
||||
|
||||
def sendSignal(self, name, *args, **kwargs):
|
||||
self.root.sendSignal(name, args, kwargs)
|
||||
def send_signal(self, name, *args, **kwargs):
|
||||
self.root.send_signal(name, args, kwargs)
|
||||
|
||||
def remote_initBridge(self, signals_handler):
|
||||
def remote_init_bridge(self, signals_handler):
|
||||
self.signals_handlers.append(signals_handler)
|
||||
log.info("registered signal handler")
|
||||
|
||||
|
|
@ -135,32 +135,32 @@ class Bridge(object):
|
|||
setattr(self.root, "remote_" + name, callback)
|
||||
# self.root.register_method(name, callback)
|
||||
|
||||
def addMethod(
|
||||
def add_method(
|
||||
self, name, int_suffix, in_sign, out_sign, method, async_=False, doc={}
|
||||
):
|
||||
"""Dynamically add a method to PB Bridge"""
|
||||
"""Dynamically add a method to PB bridge"""
|
||||
# FIXME: doc parameter is kept only temporary, the time to remove it from calls
|
||||
log.debug("Adding method {name} to PB bridge".format(name=name))
|
||||
self.register_method(name, method)
|
||||
|
||||
def addSignal(self, name, int_suffix, signature, doc={}):
|
||||
def add_signal(self, name, int_suffix, signature, doc={}):
|
||||
log.debug("Adding signal {name} to PB bridge".format(name=name))
|
||||
setattr(
|
||||
self, name, lambda *args, **kwargs: self.sendSignal(name, *args, **kwargs)
|
||||
self, name, lambda *args, **kwargs: self.send_signal(name, *args, **kwargs)
|
||||
)
|
||||
|
||||
def bridgeDeactivateSignals(self):
|
||||
def bridge_deactivate_signals(self):
|
||||
"""Stop sending signals to bridge
|
||||
|
||||
Mainly used for mobile frontends, when the frontend is paused
|
||||
"""
|
||||
self.root._bridgeDeactivateSignals()
|
||||
self.root._bridge_deactivate_signals()
|
||||
|
||||
def bridgeReactivateSignals(self):
|
||||
def bridge_reactivate_signals(self):
|
||||
"""Send again signals to bridge
|
||||
|
||||
Should only be used after bridgeDeactivateSignals has been called
|
||||
Should only be used after bridge_deactivate_signals has been called
|
||||
"""
|
||||
self.root._bridgeReactivateSignals()
|
||||
self.root._bridge_reactivate_signals()
|
||||
|
||||
##SIGNALS_PART##
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class SignalsHandler(pb.Referenceable):
|
|||
setattr(self, method_name, handler)
|
||||
|
||||
|
||||
class Bridge(object):
|
||||
class bridge(object):
|
||||
|
||||
def __init__(self):
|
||||
self.signals_handler = SignalsHandler()
|
||||
|
|
@ -75,7 +75,7 @@ class Bridge(object):
|
|||
)
|
||||
)
|
||||
|
||||
def remoteCallback(self, result, callback):
|
||||
def remote_callback(self, result, callback):
|
||||
"""call callback with argument or None
|
||||
|
||||
if result is not None not argument is used,
|
||||
|
|
@ -112,11 +112,11 @@ class Bridge(object):
|
|||
callback = args.pop()
|
||||
d = self.root.callRemote(name, *args, **kwargs)
|
||||
if callback is not None:
|
||||
d.addCallback(self.remoteCallback, callback)
|
||||
d.addCallback(self.remote_callback, callback)
|
||||
if errback is not None:
|
||||
d.addErrback(errback)
|
||||
|
||||
def _initBridgeEb(self, failure_):
|
||||
def _init_bridge_eb(self, failure_):
|
||||
log.error("Can't init bridge: {msg}".format(msg=failure_))
|
||||
return failure_
|
||||
|
||||
|
|
@ -127,28 +127,28 @@ class Bridge(object):
|
|||
"""
|
||||
self.root = root
|
||||
d = root.callRemote("initBridge", self.signals_handler)
|
||||
d.addErrback(self._initBridgeEb)
|
||||
d.addErrback(self._init_bridge_eb)
|
||||
return d
|
||||
|
||||
def getRootObjectEb(self, failure_):
|
||||
def get_root_object_eb(self, failure_):
|
||||
"""Call errback with appropriate bridge error"""
|
||||
if failure_.check(ConnectionRefusedError, ConnectError):
|
||||
raise exceptions.BridgeExceptionNoService
|
||||
else:
|
||||
raise failure_
|
||||
|
||||
def bridgeConnect(self, callback, errback):
|
||||
def bridge_connect(self, callback, errback):
|
||||
factory = pb.PBClientFactory()
|
||||
conf = config.parseMainConf()
|
||||
getConf = partial(config.getConf, conf, "bridge_pb", "")
|
||||
conn_type = getConf("connection_type", "unix_socket")
|
||||
conf = config.parse_main_conf()
|
||||
get_conf = partial(config.get_conf, conf, "bridge_pb", "")
|
||||
conn_type = get_conf("connection_type", "unix_socket")
|
||||
if conn_type == "unix_socket":
|
||||
local_dir = Path(config.getConfig(conf, "", "local_dir")).resolve()
|
||||
local_dir = Path(config.config_get(conf, "", "local_dir")).resolve()
|
||||
socket_path = local_dir / "bridge_pb"
|
||||
reactor.connectUNIX(str(socket_path), factory)
|
||||
elif conn_type == "socket":
|
||||
host = getConf("host", "localhost")
|
||||
port = int(getConf("port", 8789))
|
||||
host = get_conf("host", "localhost")
|
||||
port = int(get_conf("port", 8789))
|
||||
reactor.connectTCP(host, port, factory)
|
||||
else:
|
||||
raise ValueError(f"Unknown pb connection type: {conn_type!r}")
|
||||
|
|
@ -156,7 +156,7 @@ class Bridge(object):
|
|||
d.addCallback(self._set_root)
|
||||
if callback is not None:
|
||||
d.addCallback(lambda __: callback())
|
||||
d.addErrback(self.getRootObjectEb)
|
||||
d.addErrback(self.get_root_object_eb)
|
||||
if errback is not None:
|
||||
d.addErrback(lambda failure_: errback(failure_.value))
|
||||
return d
|
||||
|
|
@ -175,7 +175,7 @@ class AIOSignalsHandler(SignalsHandler):
|
|||
return super().register_signal(name, async_handler, iface)
|
||||
|
||||
|
||||
class AIOBridge(Bridge):
|
||||
class AIOBridge(bridge):
|
||||
|
||||
def __init__(self):
|
||||
self.signals_handler = AIOSignalsHandler()
|
||||
|
|
@ -192,8 +192,8 @@ class AIOBridge(Bridge):
|
|||
d.addErrback(self._errback)
|
||||
return d.asFuture(asyncio.get_event_loop())
|
||||
|
||||
async def bridgeConnect(self):
|
||||
d = super().bridgeConnect(callback=None, errback=None)
|
||||
async def bridge_connect(self):
|
||||
d = super().bridge_connect(callback=None, errback=None)
|
||||
return await d.asFuture(asyncio.get_event_loop())
|
||||
|
||||
##ASYNC_METHODS_PART##
|
||||
|
|
|
|||
Loading…
Reference in a new issue