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
|
|
@ -83,7 +83,7 @@ class PubsubEncryption:
|
|||
|
||||
def __init__(self, host):
|
||||
log.info(_("OpenPGP for XMPP Pubsub plugin initialization"))
|
||||
host.registerNamespace("oxps", NS_OXPS)
|
||||
host.register_namespace("oxps", NS_OXPS)
|
||||
self.host = host
|
||||
self._p = host.plugins["XEP-0060"]
|
||||
self._h = host.plugins["XEP-0334"]
|
||||
|
|
@ -94,32 +94,32 @@ class PubsubEncryption:
|
|||
"messageReceived",
|
||||
self._message_received_trigger,
|
||||
)
|
||||
host.bridge.addMethod(
|
||||
"psSecretShare",
|
||||
host.bridge.add_method(
|
||||
"ps_secret_share",
|
||||
".plugin",
|
||||
in_sign="sssass",
|
||||
out_sign="",
|
||||
method=self._ps_secret_share,
|
||||
async_=True,
|
||||
)
|
||||
host.bridge.addMethod(
|
||||
"psSecretRevoke",
|
||||
host.bridge.add_method(
|
||||
"ps_secret_revoke",
|
||||
".plugin",
|
||||
in_sign="sssass",
|
||||
out_sign="",
|
||||
method=self._ps_secret_revoke,
|
||||
async_=True,
|
||||
)
|
||||
host.bridge.addMethod(
|
||||
"psSecretRotate",
|
||||
host.bridge.add_method(
|
||||
"ps_secret_rotate",
|
||||
".plugin",
|
||||
in_sign="ssass",
|
||||
out_sign="",
|
||||
method=self._ps_secret_rotate,
|
||||
async_=True,
|
||||
)
|
||||
host.bridge.addMethod(
|
||||
"psSecretsList",
|
||||
host.bridge.add_method(
|
||||
"ps_secrets_list",
|
||||
".plugin",
|
||||
in_sign="sss",
|
||||
out_sign="s",
|
||||
|
|
@ -127,10 +127,10 @@ class PubsubEncryption:
|
|||
async_=True,
|
||||
)
|
||||
|
||||
def getHandler(self, client):
|
||||
def get_handler(self, client):
|
||||
return PubsubEncryption_Handler()
|
||||
|
||||
async def profileConnecting(self, client):
|
||||
async def profile_connecting(self, client):
|
||||
client.__storage = persistent.LazyPersistentBinaryDict(
|
||||
IMPORT_NAME, client.profile
|
||||
)
|
||||
|
|
@ -239,7 +239,7 @@ class PubsubEncryption:
|
|||
) -> defer.Deferred:
|
||||
return defer.ensureDeferred(
|
||||
self.revoke(
|
||||
self.host.getClient(profile_key),
|
||||
self.host.get_client(profile_key),
|
||||
jid.JID(service) if service else None,
|
||||
node,
|
||||
secret_id,
|
||||
|
|
@ -267,7 +267,7 @@ class PubsubEncryption:
|
|||
"""
|
||||
if service is None:
|
||||
service = client.jid.userhostJID()
|
||||
node_uri = uri.buildXMPPUri("pubsub", path=service.full(), node=node)
|
||||
node_uri = uri.build_xmpp_uri("pubsub", path=service.full(), node=node)
|
||||
shared_secrets = await self.load_secrets(client, node_uri)
|
||||
if not shared_secrets:
|
||||
raise exceptions.NotFound(f"No shared secret is known for {node_uri}")
|
||||
|
|
@ -327,7 +327,7 @@ class PubsubEncryption:
|
|||
message_elt["from"] = client.jid.full()
|
||||
message_elt["to"] = recipient.full()
|
||||
message_elt.addChild((openpgp_elt))
|
||||
self._h.addHintElements(message_elt, [self._h.HINT_STORE])
|
||||
self._h.add_hint_elements(message_elt, [self._h.HINT_STORE])
|
||||
client.send(message_elt)
|
||||
|
||||
def _ps_secret_share(
|
||||
|
|
@ -340,7 +340,7 @@ class PubsubEncryption:
|
|||
) -> defer.Deferred:
|
||||
return defer.ensureDeferred(
|
||||
self.share_secrets(
|
||||
self.host.getClient(profile_key),
|
||||
self.host.get_client(profile_key),
|
||||
jid.JID(recipient),
|
||||
jid.JID(service) if service else None,
|
||||
node,
|
||||
|
|
@ -377,7 +377,7 @@ class PubsubEncryption:
|
|||
message_elt["from"] = client.jid.full()
|
||||
message_elt["to"] = recipient.full()
|
||||
message_elt.addChild((openpgp_elt))
|
||||
self._h.addHintElements(message_elt, [self._h.HINT_STORE])
|
||||
self._h.add_hint_elements(message_elt, [self._h.HINT_STORE])
|
||||
client.send(message_elt)
|
||||
shared_secret.shared_with.add(recipient)
|
||||
|
||||
|
|
@ -399,7 +399,7 @@ class PubsubEncryption:
|
|||
"""
|
||||
if service is None:
|
||||
service = client.jid.userhostJID()
|
||||
node_uri = uri.buildXMPPUri("pubsub", path=service.full(), node=node)
|
||||
node_uri = uri.build_xmpp_uri("pubsub", path=service.full(), node=node)
|
||||
shared_secrets = await self.load_secrets(client, node_uri)
|
||||
if shared_secrets is None:
|
||||
# no secret shared yet, let's generate one
|
||||
|
|
@ -429,7 +429,7 @@ class PubsubEncryption:
|
|||
) -> defer.Deferred:
|
||||
return defer.ensureDeferred(
|
||||
self.rotate_secret(
|
||||
self.host.getClient(profile_key),
|
||||
self.host.get_client(profile_key),
|
||||
jid.JID(service) if service else None,
|
||||
node,
|
||||
[jid.JID(r) for r in recipients] or None
|
||||
|
|
@ -453,7 +453,7 @@ class PubsubEncryption:
|
|||
"""
|
||||
if service is None:
|
||||
service = client.jid.userhostJID()
|
||||
node_uri = uri.buildXMPPUri("pubsub", path=service.full(), node=node)
|
||||
node_uri = uri.build_xmpp_uri("pubsub", path=service.full(), node=node)
|
||||
shared_secrets = await self.load_secrets(client, node_uri)
|
||||
if shared_secrets is None:
|
||||
shared_secrets = {}
|
||||
|
|
@ -489,7 +489,7 @@ class PubsubEncryption:
|
|||
) -> defer.Deferred:
|
||||
d = defer.ensureDeferred(
|
||||
self.list_shared_secrets(
|
||||
self.host.getClient(profile_key),
|
||||
self.host.get_client(profile_key),
|
||||
jid.JID(service) if service else None,
|
||||
node,
|
||||
)
|
||||
|
|
@ -512,7 +512,7 @@ class PubsubEncryption:
|
|||
"""
|
||||
if service is None:
|
||||
service = client.jid.userhostJID()
|
||||
node_uri = uri.buildXMPPUri("pubsub", path=service.full(), node=node)
|
||||
node_uri = uri.build_xmpp_uri("pubsub", path=service.full(), node=node)
|
||||
shared_secrets = await self.load_secrets(client, node_uri)
|
||||
if shared_secrets is None:
|
||||
raise exceptions.NotFound(f"No shared secrets found for {node_uri}")
|
||||
|
|
@ -541,7 +541,7 @@ class PubsubEncryption:
|
|||
f"ignoring invalid <revoke> element: {e}\n{revoke_elt.toXml()}"
|
||||
)
|
||||
return
|
||||
node_uri = uri.buildXMPPUri("pubsub", path=service.full(), node=node)
|
||||
node_uri = uri.build_xmpp_uri("pubsub", path=service.full(), node=node)
|
||||
shared_secrets = await self.load_secrets(client, node_uri)
|
||||
if shared_secrets is None:
|
||||
log.warning(
|
||||
|
|
@ -604,7 +604,7 @@ class PubsubEncryption:
|
|||
shared_secret = SharedSecret(
|
||||
id=secret_id, key=key, timestamp=timestamp, origin=sender, revoked=revoked
|
||||
)
|
||||
node_uri = uri.buildXMPPUri("pubsub", path=service.full(), node=node)
|
||||
node_uri = uri.build_xmpp_uri("pubsub", path=service.full(), node=node)
|
||||
shared_secrets = await self.load_secrets(client, node_uri)
|
||||
if shared_secrets is None:
|
||||
shared_secrets = {}
|
||||
|
|
@ -636,7 +636,7 @@ class PubsubEncryption:
|
|||
) -> bool:
|
||||
if not items or not extra.get("encrypted"):
|
||||
return True
|
||||
node_uri = uri.buildXMPPUri("pubsub", path=service.full(), node=node)
|
||||
node_uri = uri.build_xmpp_uri("pubsub", path=service.full(), node=node)
|
||||
shared_secrets = await self.load_secrets(client, node_uri)
|
||||
if shared_secrets is None:
|
||||
shared_secrets = {}
|
||||
|
|
@ -713,7 +713,7 @@ class PubsubEncryption:
|
|||
)
|
||||
continue
|
||||
if shared_secrets is None:
|
||||
node_uri = uri.buildXMPPUri("pubsub", path=service.full(), node=node)
|
||||
node_uri = uri.build_xmpp_uri("pubsub", path=service.full(), node=node)
|
||||
shared_secrets = await self.load_secrets(client, node_uri)
|
||||
if shared_secrets is None:
|
||||
log.warning(
|
||||
|
|
|
|||
Loading…
Reference in a new issue