Mercurial > libervia-backend
diff sat/plugins/plugin_xep_0446.py @ 4037:524856bd7b19
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.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 08 Apr 2023 13:54:42 +0200 |
parents | 0ff265725489 |
children |
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0446.py Fri Apr 07 15:18:39 2023 +0200 +++ b/sat/plugins/plugin_xep_0446.py Sat Apr 08 13:54:42 2023 +0200 @@ -49,7 +49,7 @@ 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 @@ 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 @@ 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_)