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
|
|
@ -61,10 +61,10 @@ class Invitation(object):
|
|||
# map from namespace of the invitation to callback handling it
|
||||
self._ns_cb = {}
|
||||
|
||||
def getHandler(self, client):
|
||||
def get_handler(self, client):
|
||||
return PubsubInvitationHandler(self)
|
||||
|
||||
def registerNamespace(self, namespace, callback):
|
||||
def register_namespace(self, namespace, callback):
|
||||
"""Register a callback for a namespace
|
||||
|
||||
@param namespace(unicode): namespace handled
|
||||
|
|
@ -95,7 +95,7 @@ class Invitation(object):
|
|||
.format(namespace=namespace, callback=self._ns_cb[namespace]))
|
||||
self._ns_cb[namespace] = callback
|
||||
|
||||
def _generateBaseInvitation(self, client, invitee_jid, name, extra):
|
||||
def _generate_base_invitation(self, client, invitee_jid, name, extra):
|
||||
"""Generate common mess_data end invitation_elt
|
||||
|
||||
@param invitee_jid(jid.JID): entitee to send invitation to
|
||||
|
|
@ -113,8 +113,8 @@ class Invitation(object):
|
|||
"subject": {},
|
||||
"extra": {},
|
||||
}
|
||||
client.generateMessageXML(mess_data)
|
||||
self._h.addHintElements(mess_data["xml"], [self._h.HINT_STORE])
|
||||
client.generate_message_xml(mess_data)
|
||||
self._h.add_hint_elements(mess_data["xml"], [self._h.HINT_STORE])
|
||||
invitation_elt = mess_data["xml"].addElement("invitation", NS_INVITATION)
|
||||
if name is not None:
|
||||
invitation_elt["name"] = name
|
||||
|
|
@ -128,7 +128,7 @@ class Invitation(object):
|
|||
invitation_elt['thumb_url'] = thumb_url
|
||||
return mess_data, invitation_elt
|
||||
|
||||
def sendPubsubInvitation(
|
||||
def send_pubsub_invitation(
|
||||
self,
|
||||
client: SatXMPPEntity,
|
||||
invitee_jid: jid.JID,
|
||||
|
|
@ -145,12 +145,12 @@ class Invitation(object):
|
|||
@param node: pubsub node
|
||||
@param item_id: pubsub id
|
||||
None when the invitation is for a whole node
|
||||
@param name: see [_generateBaseInvitation]
|
||||
@param extra: see [_generateBaseInvitation]
|
||||
@param name: see [_generate_base_invitation]
|
||||
@param extra: see [_generate_base_invitation]
|
||||
"""
|
||||
if extra is None:
|
||||
extra = {}
|
||||
mess_data, invitation_elt = self._generateBaseInvitation(
|
||||
mess_data, invitation_elt = self._generate_base_invitation(
|
||||
client, invitee_jid, name, extra)
|
||||
pubsub_elt = invitation_elt.addElement("pubsub")
|
||||
pubsub_elt["service"] = service.full()
|
||||
|
|
@ -172,7 +172,7 @@ class Invitation(object):
|
|||
invitation_elt.addChild(extra.pop("element"))
|
||||
client.send(mess_data["xml"])
|
||||
|
||||
async def sendFileSharingInvitation(
|
||||
async def send_file_sharing_invitation(
|
||||
self, client, invitee_jid, service, repos_type=None, namespace=None, path=None,
|
||||
name=None, extra=None
|
||||
):
|
||||
|
|
@ -185,13 +185,13 @@ class Invitation(object):
|
|||
- "photos": photos album
|
||||
@param namespace(unicode, None): namespace of the shared repository
|
||||
@param path(unicode, None): path of the shared repository
|
||||
@param name(unicode, None): see [_generateBaseInvitation]
|
||||
@param extra(dict, None): see [_generateBaseInvitation]
|
||||
@param name(unicode, None): see [_generate_base_invitation]
|
||||
@param extra(dict, None): see [_generate_base_invitation]
|
||||
"""
|
||||
if extra is None:
|
||||
extra = {}
|
||||
li_plg = self.host.plugins["LIST_INTEREST"]
|
||||
li_plg.normaliseFileSharingService(client, service)
|
||||
li_plg.normalise_file_sharing_service(client, service)
|
||||
|
||||
# FIXME: not the best place to adapt permission, but it's necessary to check them
|
||||
# for UX
|
||||
|
|
@ -205,7 +205,7 @@ class Invitation(object):
|
|||
if "thumb_url" not in extra:
|
||||
# we have no thumbnail, we check in our own list of interests if there is one
|
||||
try:
|
||||
item_id = li_plg.getFileSharingId(service, namespace, path)
|
||||
item_id = li_plg.get_file_sharing_id(service, namespace, path)
|
||||
own_interest = await li_plg.get(client, item_id)
|
||||
except exceptions.NotFound:
|
||||
log.debug(
|
||||
|
|
@ -218,7 +218,7 @@ class Invitation(object):
|
|||
except KeyError:
|
||||
pass
|
||||
|
||||
mess_data, invitation_elt = self._generateBaseInvitation(
|
||||
mess_data, invitation_elt = self._generate_base_invitation(
|
||||
client, invitee_jid, name, extra)
|
||||
file_sharing_elt = invitation_elt.addElement("file_sharing")
|
||||
file_sharing_elt["service"] = service.full()
|
||||
|
|
@ -235,7 +235,7 @@ class Invitation(object):
|
|||
file_sharing_elt["path"] = path
|
||||
client.send(mess_data["xml"])
|
||||
|
||||
async def _parsePubsubElt(self, client, pubsub_elt):
|
||||
async def _parse_pubsub_elt(self, client, pubsub_elt):
|
||||
try:
|
||||
service = jid.JID(pubsub_elt["service"])
|
||||
node = pubsub_elt["node"]
|
||||
|
|
@ -246,7 +246,7 @@ class Invitation(object):
|
|||
|
||||
if item_id is not None:
|
||||
try:
|
||||
items, metadata = await self._p.getItems(
|
||||
items, metadata = await self._p.get_items(
|
||||
client, service, node, item_ids=[item_id]
|
||||
)
|
||||
except Exception as e:
|
||||
|
|
@ -276,7 +276,7 @@ class Invitation(object):
|
|||
|
||||
return namespace, args
|
||||
|
||||
async def _parseFileSharingElt(self, client, file_sharing_elt):
|
||||
async def _parse_file_sharing_elt(self, client, file_sharing_elt):
|
||||
try:
|
||||
service = jid.JID(file_sharing_elt["service"])
|
||||
except (RuntimeError, KeyError):
|
||||
|
|
@ -286,10 +286,10 @@ class Invitation(object):
|
|||
sharing_ns = file_sharing_elt.getAttribute("namespace")
|
||||
path = file_sharing_elt.getAttribute("path")
|
||||
args = [service, repos_type, sharing_ns, path]
|
||||
ns_fis = self.host.getNamespace("fis")
|
||||
ns_fis = self.host.get_namespace("fis")
|
||||
return ns_fis, args
|
||||
|
||||
async def onInvitation(self, message_elt, client):
|
||||
async def on_invitation(self, message_elt, client):
|
||||
log.debug("invitation received [{profile}]".format(profile=client.profile))
|
||||
invitation_elt = message_elt.invitation
|
||||
|
||||
|
|
@ -303,9 +303,9 @@ class Invitation(object):
|
|||
log.warning("unexpected element: {xml}".format(xml=elt.toXml()))
|
||||
continue
|
||||
if elt.name == "pubsub":
|
||||
method = self._parsePubsubElt
|
||||
method = self._parse_pubsub_elt
|
||||
elif elt.name == "file_sharing":
|
||||
method = self._parseFileSharingElt
|
||||
method = self._parse_file_sharing_elt
|
||||
else:
|
||||
log.warning("not implemented invitation element: {xml}".format(
|
||||
xml = elt.toXml()))
|
||||
|
|
@ -324,7 +324,7 @@ class Invitation(object):
|
|||
'No handler for namespace "{namespace}", invitation ignored')
|
||||
.format(namespace=namespace))
|
||||
else:
|
||||
await utils.asDeferred(cb, client, namespace, name, extra, *args)
|
||||
await utils.as_deferred(cb, client, namespace, name, extra, *args)
|
||||
|
||||
|
||||
@implementer(iwokkel.IDisco)
|
||||
|
|
@ -337,7 +337,7 @@ class PubsubInvitationHandler(XMPPHandler):
|
|||
self.xmlstream.addObserver(
|
||||
INVITATION,
|
||||
lambda message_elt: defer.ensureDeferred(
|
||||
self.plugin_parent.onInvitation(message_elt, client=self.parent)
|
||||
self.plugin_parent.on_invitation(message_elt, client=self.parent)
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue