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
278 changed files with 9945 additions and 9945 deletions
|
|
@ -72,7 +72,7 @@ class ExportCommandProtocol(protocol.ProcessProtocol):
|
|||
def write(self, message):
|
||||
self.transport.write(message.encode("utf-8"))
|
||||
|
||||
def boolOption(self, key):
|
||||
def bool_option(self, key):
|
||||
""" Get boolean value from options
|
||||
@param key: name of the option
|
||||
@return: True if key exists and set to "true" (case insensitive),
|
||||
|
|
@ -92,13 +92,13 @@ class CommandExport(object):
|
|||
log.info(_("Plugin command export initialization"))
|
||||
self.host = host
|
||||
self.spawned = {} # key = entity
|
||||
host.trigger.add("messageReceived", self.messageReceivedTrigger, priority=10000)
|
||||
host.bridge.addMethod(
|
||||
"exportCommand",
|
||||
host.trigger.add("messageReceived", self.message_received_trigger, priority=10000)
|
||||
host.bridge.add_method(
|
||||
"command_export",
|
||||
".plugin",
|
||||
in_sign="sasasa{ss}s",
|
||||
out_sign="",
|
||||
method=self._exportCommand,
|
||||
method=self._export_command,
|
||||
)
|
||||
|
||||
def removeProcess(self, entity, process):
|
||||
|
|
@ -113,7 +113,7 @@ class CommandExport(object):
|
|||
except ValueError:
|
||||
pass
|
||||
|
||||
def messageReceivedTrigger(self, client, message_elt, post_treat):
|
||||
def message_received_trigger(self, client, message_elt, post_treat):
|
||||
""" Check if source is linked and repeat message, else do nothing """
|
||||
from_jid = jid.JID(message_elt["from"])
|
||||
spawned_key = (from_jid.userhostJID(), client.profile)
|
||||
|
|
@ -131,15 +131,15 @@ class CommandExport(object):
|
|||
exclusive = False
|
||||
for process in processes_set:
|
||||
process.write(mess_data)
|
||||
_continue &= process.boolOption("continue")
|
||||
exclusive |= process.boolOption("exclusive")
|
||||
_continue &= process.bool_option("continue")
|
||||
exclusive |= process.bool_option("exclusive")
|
||||
if exclusive:
|
||||
raise trigger.SkipOtherTriggers
|
||||
return _continue
|
||||
|
||||
return True
|
||||
|
||||
def _exportCommand(self, command, args, targets, options, profile_key):
|
||||
def _export_command(self, command, args, targets, options, profile_key):
|
||||
""" Export a commands to authorised targets
|
||||
@param command: full path of the command to execute
|
||||
@param args: list of arguments, with command name as first one
|
||||
|
|
@ -150,7 +150,7 @@ class CommandExport(object):
|
|||
- pty: if set, launch in a pseudo terminal
|
||||
- continue: continue normal messageReceived handling
|
||||
"""
|
||||
client = self.host.getClient(profile_key)
|
||||
client = self.host.get_client(profile_key)
|
||||
for target in targets:
|
||||
try:
|
||||
_jid = jid.JID(target)
|
||||
|
|
@ -163,5 +163,5 @@ class CommandExport(object):
|
|||
process_prot = ExportCommandProtocol(self, client, _jid, options)
|
||||
self.spawned.setdefault((_jid, client.profile), set()).add(process_prot)
|
||||
reactor.spawnProcess(
|
||||
process_prot, command, args, usePTY=process_prot.boolOption("pty")
|
||||
process_prot, command, args, usePTY=process_prot.bool_option("pty")
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue