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
1 changed files with 9945 additions and 9945 deletions
|
|
@ -58,10 +58,10 @@ class AttachPlugin:
|
|||
log.info(_("plugin Attach initialization"))
|
||||
self.host = host
|
||||
self._u = host.plugins["UPLOAD"]
|
||||
host.trigger.add("sendMessage", self._sendMessageTrigger)
|
||||
host.trigger.add("sendMessageComponent", self._sendMessageTrigger)
|
||||
host.trigger.add("sendMessage", self._send_message_trigger)
|
||||
host.trigger.add("sendMessageComponent", self._send_message_trigger)
|
||||
self._attachments_handlers = {'clear': [], 'encrypted': []}
|
||||
self.register(self.defaultCanHandle, self.defaultAttach, False, -1000)
|
||||
self.register(self.default_can_handle, self.default_attach, False, -1000)
|
||||
|
||||
def register(self, can_handle, attach, encrypted=False, priority=0):
|
||||
"""Register an attachments handler
|
||||
|
|
@ -94,7 +94,7 @@ class AttachPlugin:
|
|||
handlers.sort(key=lambda h: h.priority, reverse=True)
|
||||
log.debug(f"new attachments handler: {handler}")
|
||||
|
||||
async def attachFiles(self, client, data):
|
||||
async def attach_files(self, client, data):
|
||||
"""Main method to attach file
|
||||
|
||||
It will do generic pre-treatment, and call the suitable attachments handler
|
||||
|
|
@ -135,13 +135,13 @@ class AttachPlugin:
|
|||
_("Can't resize attachment of type {main_type!r}: {attachment}")
|
||||
.format(main_type=main_type, attachment=attachment))
|
||||
|
||||
if client.encryption.isEncryptionRequested(data):
|
||||
if client.encryption.is_encryption_requested(data):
|
||||
handlers = self._attachments_handlers['encrypted']
|
||||
else:
|
||||
handlers = self._attachments_handlers['clear']
|
||||
|
||||
for handler in handlers:
|
||||
can_handle = await utils.asDeferred(handler.can_handle, client, data)
|
||||
can_handle = await utils.as_deferred(handler.can_handle, client, data)
|
||||
if can_handle:
|
||||
break
|
||||
else:
|
||||
|
|
@ -150,7 +150,7 @@ class AttachPlugin:
|
|||
destinee = data['to']
|
||||
))
|
||||
|
||||
await utils.asDeferred(handler.attach, client, data)
|
||||
await utils.as_deferred(handler.attach, client, data)
|
||||
|
||||
for dir_path in tmp_dirs_to_clean:
|
||||
log.debug(f"Cleaning temporary directory at {dir_path}")
|
||||
|
|
@ -220,7 +220,7 @@ class AttachPlugin:
|
|||
progress_id = attachment.pop("progress_id", None)
|
||||
if progress_id:
|
||||
extra["progress_id"] = progress_id
|
||||
check_certificate = self.host.memory.getParamA(
|
||||
check_certificate = self.host.memory.param_get_a(
|
||||
"check_certificate", "Connection", profile_key=client.profile)
|
||||
if not check_certificate:
|
||||
extra['ignore_tls_errors'] = True
|
||||
|
|
@ -251,19 +251,19 @@ class AttachPlugin:
|
|||
|
||||
return data
|
||||
|
||||
def _attachFiles(self, data, client):
|
||||
return defer.ensureDeferred(self.attachFiles(client, data))
|
||||
def _attach_files(self, data, client):
|
||||
return defer.ensureDeferred(self.attach_files(client, data))
|
||||
|
||||
def _sendMessageTrigger(
|
||||
def _send_message_trigger(
|
||||
self, client, mess_data, pre_xml_treatments, post_xml_treatments):
|
||||
if mess_data['extra'].get(C.KEY_ATTACHMENTS):
|
||||
post_xml_treatments.addCallback(self._attachFiles, client=client)
|
||||
post_xml_treatments.addCallback(self._attach_files, client=client)
|
||||
return True
|
||||
|
||||
async def defaultCanHandle(self, client, data):
|
||||
async def default_can_handle(self, client, data):
|
||||
return True
|
||||
|
||||
async def defaultAttach(self, client, data):
|
||||
async def default_attach(self, client, data):
|
||||
await self.upload_files(client, data)
|
||||
# TODO: handle xhtml-im
|
||||
body_elt = data["xml"].body
|
||||
|
|
|
|||
Loading…
Reference in a new issue