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

View file

@ -49,7 +49,7 @@ class XEP_0446:
def __init__(self, host):
log.info(_("XEP-0446 (File Metadata Element) plugin initialization"))
host.registerNamespace("file-metadata", NS_FILE_METADATA)
host.register_namespace("file-metadata", NS_FILE_METADATA)
self._hash = host.plugins["XEP-0300"]
def get_file_metadata_elt(
@ -95,7 +95,7 @@ class XEP_0446:
file_elt.addElement(name, content=str(value))
if file_hash is not None:
hash_algo, hash_ = file_hash
file_elt.addChild(self._hash.buildHashElt(hash_, hash_algo))
file_elt.addChild(self._hash.build_hash_elt(hash_, hash_algo))
if date is not None:
file_elt.addElement("date", utils.xmpp_date(date))
if thumbnail is not None:
@ -151,12 +151,12 @@ class XEP_0446:
raise exceptions.InternalError
try:
algo, hash_ = self._hash.parseHashElt(file_metadata_elt)
algo, hash_ = self._hash.parse_hash_elt(file_metadata_elt)
except exceptions.NotFound:
pass
except exceptions.DataError:
from sat.tools.xml_tools import pFmtElt
log.warning("invalid <hash/> element:\n{pFmtElt(file_metadata_elt)}")
from sat.tools.xml_tools import p_fmt_elt
log.warning("invalid <hash/> element:\n{p_fmt_elt(file_metadata_elt)}")
else:
data["file_hash"] = (algo, hash_)