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
|
|
@ -53,26 +53,26 @@ class XEP_0191:
|
|||
|
||||
def __init__(self, host):
|
||||
log.info(_("Blocking Command initialization"))
|
||||
host.registerNamespace("blocking", NS_BLOCKING)
|
||||
host.register_namespace("blocking", NS_BLOCKING)
|
||||
self.host = host
|
||||
host.bridge.addMethod(
|
||||
"blockingList",
|
||||
host.bridge.add_method(
|
||||
"blocking_list",
|
||||
".plugin",
|
||||
in_sign="s",
|
||||
out_sign="as",
|
||||
method=self._blockList,
|
||||
method=self._block_list,
|
||||
async_=True,
|
||||
)
|
||||
host.bridge.addMethod(
|
||||
"blockingBlock",
|
||||
host.bridge.add_method(
|
||||
"blocking_block",
|
||||
".plugin",
|
||||
in_sign="ass",
|
||||
out_sign="",
|
||||
method=self._block,
|
||||
async_=True,
|
||||
)
|
||||
host.bridge.addMethod(
|
||||
"blockingUnblock",
|
||||
host.bridge.add_method(
|
||||
"blocking_unblock",
|
||||
".plugin",
|
||||
in_sign="ass",
|
||||
out_sign="",
|
||||
|
|
@ -80,20 +80,20 @@ class XEP_0191:
|
|||
async_=True,
|
||||
)
|
||||
|
||||
def getHandler(self, client):
|
||||
def get_handler(self, client):
|
||||
return XEP_0191_Handler(self)
|
||||
|
||||
@ensure_deferred
|
||||
async def _blockList(
|
||||
async def _block_list(
|
||||
self,
|
||||
profile_key=C.PROF_KEY_NONE
|
||||
) -> List[str]:
|
||||
client = self.host.getClient(profile_key)
|
||||
blocked_jids = await self.blockList(client)
|
||||
client = self.host.get_client(profile_key)
|
||||
blocked_jids = await self.block_list(client)
|
||||
return [j.full() for j in blocked_jids]
|
||||
|
||||
async def blockList(self, client: SatXMPPEntity) -> Set[jid.JID]:
|
||||
await self.host.checkFeature(client, NS_BLOCKING)
|
||||
async def block_list(self, client: SatXMPPEntity) -> Set[jid.JID]:
|
||||
await self.host.check_feature(client, NS_BLOCKING)
|
||||
iq_elt = client.IQ("get")
|
||||
iq_elt.addElement((NS_BLOCKING, "blocklist"))
|
||||
iq_result_elt = await iq_elt.send()
|
||||
|
|
@ -118,13 +118,13 @@ class XEP_0191:
|
|||
entities: List[str],
|
||||
profile_key: str = C.PROF_KEY_NONE
|
||||
) -> str:
|
||||
client = self.host.getClient(profile_key)
|
||||
client = self.host.get_client(profile_key)
|
||||
return defer.ensureDeferred(
|
||||
self.block(client, [jid.JID(entity) for entity in entities])
|
||||
)
|
||||
|
||||
async def block(self, client: SatXMPPEntity, entities: List[jid.JID]) -> None:
|
||||
await self.host.checkFeature(client, NS_BLOCKING)
|
||||
await self.host.check_feature(client, NS_BLOCKING)
|
||||
iq_elt = client.IQ("set")
|
||||
block_elt = iq_elt.addElement((NS_BLOCKING, "block"))
|
||||
for entity in entities:
|
||||
|
|
@ -137,13 +137,13 @@ class XEP_0191:
|
|||
entities: List[str],
|
||||
profile_key: str = C.PROF_KEY_NONE
|
||||
) -> None:
|
||||
client = self.host.getClient(profile_key)
|
||||
client = self.host.get_client(profile_key)
|
||||
return defer.ensureDeferred(
|
||||
self.unblock(client, [jid.JID(e) for e in entities])
|
||||
)
|
||||
|
||||
async def unblock(self, client: SatXMPPEntity, entities: List[jid.JID]) -> None:
|
||||
await self.host.checkFeature(client, NS_BLOCKING)
|
||||
await self.host.check_feature(client, NS_BLOCKING)
|
||||
iq_elt = client.IQ("set")
|
||||
unblock_elt = iq_elt.addElement((NS_BLOCKING, "unblock"))
|
||||
for entity in entities:
|
||||
|
|
@ -151,7 +151,7 @@ class XEP_0191:
|
|||
item_elt["jid"] = entity.full()
|
||||
await iq_elt.send()
|
||||
|
||||
def onBlockPush(self, iq_elt: domish.Element, client: SatXMPPEntity) -> None:
|
||||
def on_block_push(self, iq_elt: domish.Element, client: SatXMPPEntity) -> None:
|
||||
# TODO: send notification to user
|
||||
iq_elt.handled = True
|
||||
for item_elt in iq_elt.block.elements(NS_BLOCKING, "item"):
|
||||
|
|
@ -164,7 +164,7 @@ class XEP_0191:
|
|||
iq_result_elt = xmlstream.toResponse(iq_elt, "result")
|
||||
client.send(iq_result_elt)
|
||||
|
||||
def onUnblockPush(self, iq_elt: domish.Element, client: SatXMPPEntity) -> None:
|
||||
def on_unblock_push(self, iq_elt: domish.Element, client: SatXMPPEntity) -> None:
|
||||
# TODO: send notification to user
|
||||
iq_elt.handled = True
|
||||
items = list(iq_elt.unblock.elements(NS_BLOCKING, "item"))
|
||||
|
|
@ -193,13 +193,13 @@ class XEP_0191_Handler(xmlstream.XMPPHandler):
|
|||
def connectionInitialized(self):
|
||||
self.xmlstream.addObserver(
|
||||
IQ_BLOCK_PUSH,
|
||||
self.plugin_parent.onBlockPush,
|
||||
self.plugin_parent.on_block_push,
|
||||
client=self.parent
|
||||
|
||||
)
|
||||
self.xmlstream.addObserver(
|
||||
IQ_UNBLOCK_PUSH,
|
||||
self.plugin_parent.onUnblockPush,
|
||||
self.plugin_parent.on_unblock_push,
|
||||
client=self.parent
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue