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
|
|
@ -197,7 +197,7 @@ class GPGProvider(ABC):
|
|||
|
||||
@abstractmethod
|
||||
def import_public_key(self, packet: bytes) -> GPGPublicKey:
|
||||
"""Import a public key from a key material packet according to RFC 4880 §5.5.
|
||||
"""import a public key from a key material packet according to RFC 4880 §5.5.
|
||||
|
||||
OpenPGP's ASCII Armor is not used.
|
||||
|
||||
|
|
@ -1013,7 +1013,7 @@ class XEP_0373:
|
|||
|
||||
# Add configuration option to choose between manual trust and BTBV as the trust
|
||||
# model
|
||||
host.memory.updateParams(DEFAULT_TRUST_MODEL_PARAM)
|
||||
host.memory.update_params(DEFAULT_TRUST_MODEL_PARAM)
|
||||
|
||||
self.__xep_0045 = cast(Optional[XEP_0045], host.plugins.get("XEP-0045"))
|
||||
self.__xep_0060 = cast(XEP_0060, host.plugins["XEP-0060"])
|
||||
|
|
@ -1021,7 +1021,7 @@ class XEP_0373:
|
|||
self.__storage: Dict[str, persistent.LazyPersistentBinaryDict] = {}
|
||||
|
||||
xep_0163 = cast(XEP_0163, host.plugins["XEP-0163"])
|
||||
xep_0163.addPEPEvent(
|
||||
xep_0163.add_pep_event(
|
||||
"OX_PUBLIC_KEYS_LIST",
|
||||
PUBLIC_KEYS_LIST_NODE,
|
||||
lambda items_event, profile: defer.ensureDeferred(
|
||||
|
|
@ -1029,10 +1029,10 @@ class XEP_0373:
|
|||
)
|
||||
)
|
||||
|
||||
async def profileConnecting(self, client):
|
||||
async def profile_connecting(self, client):
|
||||
client.gpg_provider = get_gpg_provider(self.host, client)
|
||||
|
||||
async def profileConnected( # pylint: disable=invalid-name
|
||||
async def profile_connected( # pylint: disable=invalid-name
|
||||
self,
|
||||
client: SatXMPPClient
|
||||
) -> None:
|
||||
|
|
@ -1061,7 +1061,7 @@ class XEP_0373:
|
|||
@param profile: The profile this event belongs to.
|
||||
"""
|
||||
|
||||
client = self.host.getClient(profile)
|
||||
client = self.host.get_client(profile)
|
||||
|
||||
sender = cast(jid.JID, items_event.sender)
|
||||
items = cast(List[domish.Element], items_event.items)
|
||||
|
|
@ -1323,7 +1323,7 @@ class XEP_0373:
|
|||
encryption_keys: Set[GPGPublicKey] = set()
|
||||
|
||||
for recipient_jid in recipient_jids:
|
||||
# Import all keys of the recipient
|
||||
# import all keys of the recipient
|
||||
all_public_keys = await self.import_all_public_keys(client, recipient_jid)
|
||||
|
||||
# Filter for keys that can encrypt
|
||||
|
|
@ -1379,7 +1379,7 @@ class XEP_0373:
|
|||
self.list_secret_keys(client)
|
||||
))
|
||||
|
||||
# Import all keys of the sender
|
||||
# import all keys of the sender
|
||||
all_public_keys = await self.import_all_public_keys(client, sender_jid)
|
||||
|
||||
# Filter for keys that can sign
|
||||
|
|
@ -1471,7 +1471,7 @@ class XEP_0373:
|
|||
pubkey_elt.addElement("data", content=base64.b64encode(packet).decode("ASCII"))
|
||||
|
||||
try:
|
||||
await self.__xep_0060.sendItem(
|
||||
await self.__xep_0060.send_item(
|
||||
client,
|
||||
client.jid.userhostJID(),
|
||||
node,
|
||||
|
|
@ -1495,7 +1495,7 @@ class XEP_0373:
|
|||
client: SatXMPPClient,
|
||||
entity_jid: jid.JID
|
||||
) -> Set[GPGPublicKey]:
|
||||
"""Import all public keys of a JID that have not been imported before.
|
||||
"""import all public keys of a JID that have not been imported before.
|
||||
|
||||
@param client: The client.
|
||||
@param jid: The JID. Can be a bare JID.
|
||||
|
|
@ -1539,7 +1539,7 @@ class XEP_0373:
|
|||
)
|
||||
except Exception as e:
|
||||
log.warning(
|
||||
f"Import of public key {missing_key.fingerprint} owned by"
|
||||
f"import of public key {missing_key.fingerprint} owned by"
|
||||
f" {entity_jid.userhost()} failed, ignoring: {e}"
|
||||
)
|
||||
|
||||
|
|
@ -1551,7 +1551,7 @@ class XEP_0373:
|
|||
jid: jid.JID,
|
||||
fingerprint: str
|
||||
) -> GPGPublicKey:
|
||||
"""Import a public key.
|
||||
"""import a public key.
|
||||
|
||||
@param client: The client.
|
||||
@param jid: The JID owning the public key. Can be a bare JID.
|
||||
|
|
@ -1569,7 +1569,7 @@ class XEP_0373:
|
|||
node = f"urn:xmpp:openpgp:0:public-keys:{fingerprint}"
|
||||
|
||||
try:
|
||||
items, __ = await self.__xep_0060.getItems(
|
||||
items, __ = await self.__xep_0060.get_items(
|
||||
client,
|
||||
jid.userhostJID(),
|
||||
node,
|
||||
|
|
@ -1644,7 +1644,7 @@ class XEP_0373:
|
|||
pubkey_metadata_elt["date"] = format_datetime(public_key_metadata.timestamp)
|
||||
|
||||
try:
|
||||
await self.__xep_0060.sendItem(
|
||||
await self.__xep_0060.send_item(
|
||||
client,
|
||||
client.jid.userhostJID(),
|
||||
node,
|
||||
|
|
@ -1681,7 +1681,7 @@ class XEP_0373:
|
|||
node = "urn:xmpp:openpgp:0:public-keys"
|
||||
|
||||
try:
|
||||
items, __ = await self.__xep_0060.getItems(
|
||||
items, __ = await self.__xep_0060.get_items(
|
||||
client,
|
||||
jid.userhostJID(),
|
||||
node,
|
||||
|
|
@ -1741,7 +1741,7 @@ class XEP_0373:
|
|||
"""
|
||||
|
||||
try:
|
||||
infos = cast(DiscoInfo, await self.host.memory.disco.getInfos(
|
||||
infos = cast(DiscoInfo, await self.host.memory.disco.get_infos(
|
||||
client,
|
||||
client.jid.userhostJID()
|
||||
))
|
||||
|
|
@ -1769,7 +1769,7 @@ class XEP_0373:
|
|||
node = "urn:xmpp:openpgp:0:secret-key"
|
||||
|
||||
try:
|
||||
items, __ = await self.__xep_0060.getItems(
|
||||
items, __ = await self.__xep_0060.get_items(
|
||||
client,
|
||||
client.jid.userhostJID(),
|
||||
node,
|
||||
|
|
@ -1834,7 +1834,7 @@ class XEP_0373:
|
|||
secretkey_elt.addContent(base64.b64encode(ciphertext).decode("ASCII"))
|
||||
|
||||
try:
|
||||
await self.__xep_0060.sendItem(
|
||||
await self.__xep_0060.send_item(
|
||||
client,
|
||||
client.jid.userhostJID(),
|
||||
node,
|
||||
|
|
@ -1888,7 +1888,7 @@ class XEP_0373:
|
|||
ciphertext: bytes,
|
||||
backup_code: str
|
||||
) -> Set[GPGSecretKey]:
|
||||
"""Import previously downloaded secret keys.
|
||||
"""import previously downloaded secret keys.
|
||||
|
||||
The downloading and importing steps are separate since a backup code is required
|
||||
for the import and it should be possible to try multiple backup codes without
|
||||
|
|
@ -1930,7 +1930,7 @@ class XEP_0373:
|
|||
bare_jids: Set[jid.JID] = set()
|
||||
|
||||
try:
|
||||
room = cast(muc.Room, xep_0045.getRoom(client, room_jid))
|
||||
room = cast(muc.Room, xep_0045.get_room(client, room_jid))
|
||||
except exceptions.NotFound as e:
|
||||
raise exceptions.InternalError(
|
||||
"Participant list of unjoined MUC requested."
|
||||
|
|
@ -1988,7 +1988,7 @@ class XEP_0373:
|
|||
|
||||
await self.__storage[client.profile].force(key, trust_level.name)
|
||||
|
||||
async def getTrustUI( # pylint: disable=invalid-name
|
||||
async def get_trust_ui( # pylint: disable=invalid-name
|
||||
self,
|
||||
client: SatXMPPClient,
|
||||
entity: jid.JID
|
||||
|
|
@ -2004,7 +2004,7 @@ class XEP_0373:
|
|||
raise ValueError("A bare JID is expected.")
|
||||
|
||||
bare_jids: Set[jid.JID]
|
||||
if self.__xep_0045 is not None and self.__xep_0045.isJoinedRoom(client, entity):
|
||||
if self.__xep_0045 is not None and self.__xep_0045.is_joined_room(client, entity):
|
||||
bare_jids = self.__get_joined_muc_users(client, self.__xep_0045, entity)
|
||||
else:
|
||||
bare_jids = { entity.userhostJID() }
|
||||
|
|
@ -2031,7 +2031,7 @@ class XEP_0373:
|
|||
|
||||
data_form_result = cast(
|
||||
Dict[str, str],
|
||||
xml_tools.XMLUIResult2DataFormResult(data)
|
||||
xml_tools.xmlui_result_2_data_form_result(data)
|
||||
)
|
||||
for key, value in data_form_result.items():
|
||||
if not key.startswith("trust_"):
|
||||
|
|
@ -2048,7 +2048,7 @@ class XEP_0373:
|
|||
|
||||
return {}
|
||||
|
||||
submit_id = self.host.registerCallback(callback, with_data=True, one_shot=True)
|
||||
submit_id = self.host.register_callback(callback, with_data=True, one_shot=True)
|
||||
|
||||
result = xml_tools.XMLUI(
|
||||
panel_type=C.XMLUI_FORM,
|
||||
|
|
@ -2070,7 +2070,7 @@ class XEP_0373:
|
|||
|
||||
own_secret_keys = self.list_secret_keys(client)
|
||||
|
||||
trust_ui.changeContainer("label")
|
||||
trust_ui.change_container("label")
|
||||
for index, secret_key in enumerate(own_secret_keys):
|
||||
trust_ui.addLabel(D_(f"Own secret key {index} fingerprint"))
|
||||
trust_ui.addText(secret_key.public_key.fingerprint)
|
||||
|
|
|
|||
Loading…
Reference in a new issue