diff sat/plugins/plugin_xep_0060.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 9456852d3286
children
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0060.py	Fri Apr 07 15:18:39 2023 +0200
+++ b/sat/plugins/plugin_xep_0060.py	Sat Apr 08 13:54:42 2023 +0200
@@ -111,224 +111,224 @@
         self._mam = host.plugins.get("XEP-0313")
         self._node_cb = {}  # dictionnary of callbacks for node (key: node, value: list of callbacks)
         self.rt_sessions = sat_defer.RTDeferredSessions()
-        host.bridge.addMethod(
-            "psNodeCreate",
+        host.bridge.add_method(
+            "ps_node_create",
             ".plugin",
             in_sign="ssa{ss}s",
             out_sign="s",
-            method=self._createNode,
+            method=self._create_node,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psNodeConfigurationGet",
+        host.bridge.add_method(
+            "ps_node_configuration_get",
             ".plugin",
             in_sign="sss",
             out_sign="a{ss}",
-            method=self._getNodeConfiguration,
+            method=self._get_node_configuration,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psNodeConfigurationSet",
+        host.bridge.add_method(
+            "ps_node_configuration_set",
             ".plugin",
             in_sign="ssa{ss}s",
             out_sign="",
-            method=self._setNodeConfiguration,
+            method=self._set_node_configuration,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psNodeAffiliationsGet",
+        host.bridge.add_method(
+            "ps_node_affiliations_get",
             ".plugin",
             in_sign="sss",
             out_sign="a{ss}",
-            method=self._getNodeAffiliations,
+            method=self._get_node_affiliations,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psNodeAffiliationsSet",
+        host.bridge.add_method(
+            "ps_node_affiliations_set",
             ".plugin",
             in_sign="ssa{ss}s",
             out_sign="",
-            method=self._setNodeAffiliations,
+            method=self._set_node_affiliations,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psNodeSubscriptionsGet",
+        host.bridge.add_method(
+            "ps_node_subscriptions_get",
             ".plugin",
             in_sign="sss",
             out_sign="a{ss}",
-            method=self._getNodeSubscriptions,
+            method=self._get_node_subscriptions,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psNodeSubscriptionsSet",
+        host.bridge.add_method(
+            "ps_node_subscriptions_set",
             ".plugin",
             in_sign="ssa{ss}s",
             out_sign="",
-            method=self._setNodeSubscriptions,
+            method=self._set_node_subscriptions,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psNodePurge",
+        host.bridge.add_method(
+            "ps_node_purge",
             ".plugin",
             in_sign="sss",
             out_sign="",
-            method=self._purgeNode,
+            method=self._purge_node,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psNodeDelete",
+        host.bridge.add_method(
+            "ps_node_delete",
             ".plugin",
             in_sign="sss",
             out_sign="",
-            method=self._deleteNode,
+            method=self._delete_node,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psNodeWatchAdd",
+        host.bridge.add_method(
+            "ps_node_watch_add",
             ".plugin",
             in_sign="sss",
             out_sign="",
             method=self._addWatch,
             async_=False,
         )
-        host.bridge.addMethod(
-            "psNodeWatchRemove",
+        host.bridge.add_method(
+            "ps_node_watch_remove",
             ".plugin",
             in_sign="sss",
             out_sign="",
-            method=self._removeWatch,
+            method=self._remove_watch,
             async_=False,
         )
-        host.bridge.addMethod(
-            "psAffiliationsGet",
+        host.bridge.add_method(
+            "ps_affiliations_get",
             ".plugin",
             in_sign="sss",
             out_sign="a{ss}",
-            method=self._getAffiliations,
+            method=self._get_affiliations,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psItemsGet",
+        host.bridge.add_method(
+            "ps_items_get",
             ".plugin",
             in_sign="ssiassss",
             out_sign="s",
-            method=self._getItems,
+            method=self._get_items,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psItemSend",
+        host.bridge.add_method(
+            "ps_item_send",
             ".plugin",
             in_sign="ssssss",
             out_sign="s",
-            method=self._sendItem,
+            method=self._send_item,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psItemsSend",
+        host.bridge.add_method(
+            "ps_items_send",
             ".plugin",
             in_sign="ssasss",
             out_sign="as",
-            method=self._sendItems,
+            method=self._send_items,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psItemRetract",
+        host.bridge.add_method(
+            "ps_item_retract",
             ".plugin",
             in_sign="sssbs",
             out_sign="",
-            method=self._retractItem,
+            method=self._retract_item,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psItemsRetract",
+        host.bridge.add_method(
+            "ps_items_retract",
             ".plugin",
             in_sign="ssasbs",
             out_sign="",
-            method=self._retractItems,
+            method=self._retract_items,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psItemRename",
+        host.bridge.add_method(
+            "ps_item_rename",
             ".plugin",
             in_sign="sssss",
             out_sign="",
-            method=self._renameItem,
+            method=self._rename_item,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psSubscribe",
+        host.bridge.add_method(
+            "ps_subscribe",
             ".plugin",
             in_sign="ssss",
             out_sign="s",
             method=self._subscribe,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psUnsubscribe",
+        host.bridge.add_method(
+            "ps_unsubscribe",
             ".plugin",
             in_sign="sss",
             out_sign="",
             method=self._unsubscribe,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psSubscriptionsGet",
+        host.bridge.add_method(
+            "ps_subscriptions_get",
             ".plugin",
             in_sign="sss",
             out_sign="s",
             method=self._subscriptions,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psSubscribeToMany",
+        host.bridge.add_method(
+            "ps_subscribe_to_many",
             ".plugin",
             in_sign="a(ss)sa{ss}s",
             out_sign="s",
-            method=self._subscribeToMany,
+            method=self._subscribe_to_many,
         )
-        host.bridge.addMethod(
-            "psGetSubscribeRTResult",
+        host.bridge.add_method(
+            "ps_get_subscribe_rt_result",
             ".plugin",
             in_sign="ss",
             out_sign="(ua(sss))",
-            method=self._manySubscribeRTResult,
+            method=self._many_subscribe_rt_result,
             async_=True,
         )
-        host.bridge.addMethod(
-            "psGetFromMany",
+        host.bridge.add_method(
+            "ps_get_from_many",
             ".plugin",
             in_sign="a(ss)iss",
             out_sign="s",
-            method=self._getFromMany,
+            method=self._get_from_many,
         )
-        host.bridge.addMethod(
-            "psGetFromManyRTResult",
+        host.bridge.add_method(
+            "ps_get_from_many_rt_result",
             ".plugin",
             in_sign="ss",
             out_sign="(ua(sssasa{ss}))",
-            method=self._getFromManyRTResult,
+            method=self._get_from_many_rt_result,
             async_=True,
         )
 
         #  high level observer method
-        host.bridge.addSignal(
-            "psEvent", ".plugin", signature="ssssss"
+        host.bridge.add_signal(
+            "ps_event", ".plugin", signature="ssssss"
         )  # args: category, service(jid), node, type (C.PS_ITEMS, C.PS_DELETE), data, profile
 
         # low level observer method, used if service/node is in watching list (see psNodeWatch* methods)
-        host.bridge.addSignal(
-            "psEventRaw", ".plugin", signature="sssass"
+        host.bridge.add_signal(
+            "ps_event_raw", ".plugin", signature="sssass"
         )  # args: service(jid), node, type (C.PS_ITEMS, C.PS_DELETE), list of item_xml, profile
 
-    def getHandler(self, client):
+    def get_handler(self, client):
         client.pubsub_client = SatPubSubClient(self.host, self)
         return client.pubsub_client
 
-    async def profileConnected(self, client):
+    async def profile_connected(self, client):
         client.pubsub_watching = set()
         try:
             client.pubsub_service = jid.JID(
-                self.host.memory.getConfig("", "pubsub_service")
+                self.host.memory.config_get("", "pubsub_service")
             )
         except RuntimeError:
             log.info(
@@ -337,11 +337,11 @@
                     "we find"
                 )
             )
-            pubsub_services = await self.host.findServiceEntities(
+            pubsub_services = await self.host.find_service_entities(
                 client, "pubsub", "service"
             )
             for service_jid in pubsub_services:
-                infos = await self.host.memory.disco.getInfos(client, service_jid)
+                infos = await self.host.memory.disco.get_infos(client, service_jid)
                 if not DEFAULT_PUBSUB_MIN_FEAT.issubset(infos.features):
                     continue
                 names = {(n or "").lower() for n in infos.identities.values()}
@@ -367,9 +367,9 @@
             )
             log.info(f"default pubsub service: {pubsub_service_str}")
 
-    def getFeatures(self, profile):
+    def features_get(self, profile):
         try:
-            client = self.host.getClient(profile)
+            client = self.host.get_client(profile)
         except exceptions.ProfileNotSetError:
             return {}
         try:
@@ -379,13 +379,13 @@
                 else ""
             }
         except AttributeError:
-            if self.host.isConnected(profile):
+            if self.host.is_connected(profile):
                 log.debug("Profile is not connected, service is not checked yet")
             else:
                 log.error("Service should be available !")
             return {}
 
-    def parseExtra(self, extra):
+    def parse_extra(self, extra):
         """Parse extra dictionnary
 
         used bridge's extra dictionnaries
@@ -407,13 +407,13 @@
             if self._rsm is None:
                 rsm_request = None
             else:
-                rsm_request = self._rsm.parseExtra(extra)
+                rsm_request = self._rsm.parse_extra(extra)
 
             # mam
             if self._mam is None:
                 mam_request = None
             else:
-                mam_request = self._mam.parseExtra(extra, with_rsm=False)
+                mam_request = self._mam.parse_extra(extra, with_rsm=False)
 
             if mam_request is not None:
                 assert "mam" not in extra
@@ -421,7 +421,7 @@
 
         return Extra(rsm_request, extra)
 
-    def addManagedNode(
+    def add_managed_node(
         self,
         node: str,
         priority: int = 0,
@@ -449,7 +449,7 @@
             cb_list.append((cb, priority))
             cb_list.sort(key=lambda c: c[1], reverse=True)
 
-    def removeManagedNode(self, node, *args):
+    def remove_managed_node(self, node, *args):
         """Add a handler for a node
 
         @param node(unicode): node to monitor
@@ -490,7 +490,7 @@
     #     @param profile (str): %(doc_profile)s
     #     @return: deferred which fire a list of nodes
     #     """
-    #     client = self.host.getClient(profile)
+    #     client = self.host.get_client(profile)
     #     d = self.host.getDiscoItems(client, service, nodeIdentifier)
     #     d.addCallback(lambda result: [item.getAttribute('node') for item in result.toElement().children if item.hasAttribute('node')])
     #     return d
@@ -512,21 +512,21 @@
     #     d.addCallback(lambda subs: [sub.getAttribute('node') for sub in subs if sub.getAttribute('subscription') == filter_])
     #     return d
 
-    def _sendItem(self, service, nodeIdentifier, payload, item_id=None, extra_ser="",
+    def _send_item(self, service, nodeIdentifier, payload, item_id=None, extra_ser="",
                   profile_key=C.PROF_KEY_NONE):
-        client = self.host.getClient(profile_key)
+        client = self.host.get_client(profile_key)
         service = None if not service else jid.JID(service)
         payload = xml_tools.parse(payload)
         extra = data_format.deserialise(extra_ser)
-        d = defer.ensureDeferred(self.sendItem(
+        d = defer.ensureDeferred(self.send_item(
             client, service, nodeIdentifier, payload, item_id or None, extra
         ))
         d.addCallback(lambda ret: ret or "")
         return d
 
-    def _sendItems(self, service, nodeIdentifier, items, extra_ser=None,
+    def _send_items(self, service, nodeIdentifier, items, extra_ser=None,
                   profile_key=C.PROF_KEY_NONE):
-        client = self.host.getClient(profile_key)
+        client = self.host.get_client(profile_key)
         service = None if not service else jid.JID(service)
         try:
             items = [xml_tools.parse(item) for item in items]
@@ -534,11 +534,11 @@
             raise exceptions.DataError(_("Can't parse items: {msg}").format(
                 msg=e))
         extra = data_format.deserialise(extra_ser)
-        return defer.ensureDeferred(self.sendItems(
+        return defer.ensureDeferred(self.send_items(
             client, service, nodeIdentifier, items, extra=extra
         ))
 
-    async def sendItem(
+    async def send_item(
         self,
         client: SatXMPPClient,
         service: Union[jid.JID, None],
@@ -561,7 +561,7 @@
         if item_id is not None:
             item_elt['id'] = item_id
         item_elt.addChild(payload)
-        published_ids = await self.sendItems(
+        published_ids = await self.send_items(
             client,
             service,
             nodeIdentifier,
@@ -573,7 +573,7 @@
         except IndexError:
             return item_id
 
-    async def sendItems(
+    async def send_items(
         self,
         client: SatXMPPEntity,
         service: Optional[jid.JID],
@@ -676,7 +676,7 @@
             sender = client.jid
         if extra is None:
             extra = {}
-        if not await self.host.trigger.asyncPoint(
+        if not await self.host.trigger.async_point(
             "XEP-0060_publish", client, service, nodeIdentifier, items, options, sender,
             extra
         ):
@@ -687,7 +687,7 @@
         )
         return iq_result_elt
 
-    def _unwrapMAMMessage(self, message_elt):
+    def _unwrap_mam_message(self, message_elt):
         try:
             item_elt = reduce(
                 lambda elt, ns_name: next(elt.elements(*ns_name)),
@@ -703,22 +703,22 @@
             raise exceptions.DataError("Can't find Item in MAM message element")
         return item_elt
 
-    def serialiseItems(self, items_data):
+    def serialise_items(self, items_data):
         items, metadata = items_data
         metadata['items'] = items
         return data_format.serialise(metadata)
 
-    def _getItems(self, service="", node="", max_items=10, item_ids=None, sub_id=None,
+    def _get_items(self, service="", node="", max_items=10, item_ids=None, sub_id=None,
                   extra="", profile_key=C.PROF_KEY_NONE):
         """Get items from pubsub node
 
         @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit
         """
-        client = self.host.getClient(profile_key)
+        client = self.host.get_client(profile_key)
         service = jid.JID(service) if service else None
         max_items = None if max_items == C.NO_LIMIT else max_items
-        extra = self.parseExtra(data_format.deserialise(extra))
-        d = defer.ensureDeferred(self.getItems(
+        extra = self.parse_extra(data_format.deserialise(extra))
+        d = defer.ensureDeferred(self.get_items(
             client,
             service,
             node,
@@ -728,11 +728,11 @@
             extra.rsm_request,
             extra.extra,
         ))
-        d.addCallback(self.transItemsData)
-        d.addCallback(self.serialiseItems)
+        d.addCallback(self.trans_items_data)
+        d.addCallback(self.serialise_items)
         return d
 
-    async def getItems(
+    async def get_items(
         self,
         client: SatXMPPEntity,
         service: Optional[jid.JID],
@@ -767,7 +767,7 @@
             raise ValueError("items_id can't be used with rsm")
         if extra is None:
             extra = {}
-        cont, ret = await self.host.trigger.asyncReturnPoint(
+        cont, ret = await self.host.trigger.async_return_point(
             "XEP-0060_getItems", client, service, node, max_items, item_ids, sub_id,
             rsm_request, extra
         )
@@ -788,7 +788,7 @@
                 extra = extra
             ))
             # we have no MAM data here, so we add None
-            d.addErrback(sat_defer.stanza2NotFound)
+            d.addErrback(sat_defer.stanza_2_not_found)
             d.addTimeout(TIMEOUT, reactor)
             items, rsm_response = await d
             mam_response = None
@@ -804,7 +804,7 @@
                 mam_query.node = node
             elif mam_query.node != node:
                 raise exceptions.DataError(
-                    "MAM query node is incoherent with getItems's node"
+                    "MAM query node is incoherent with get_items's node"
                 )
             if mam_query.rsm is None:
                 mam_query.rsm = rsm_request
@@ -813,8 +813,8 @@
                     raise exceptions.DataError(
                         "Conflict between RSM request and MAM's RSM request"
                     )
-            items, rsm_response, mam_response = await self._mam.getArchives(
-                client, mam_query, service, self._unwrapMAMMessage
+            items, rsm_response, mam_response = await self._mam.get_archives(
+                client, mam_query, service, self._unwrap_mam_message
             )
 
         try:
@@ -835,7 +835,7 @@
         metadata = {
             "service": service_jid,
             "node": node,
-            "uri": self.getNodeURI(service_jid, node),
+            "uri": self.get_node_uri(service_jid, node),
         }
         if mam_response is not None:
             # mam_response is a dict with "complete" and "stable" keys
@@ -875,32 +875,32 @@
     #             - list of items
     #             - RSM response data
     #     """
-    #     client = self.host.getClient(profile_key)
+    #     client = self.host.get_client(profile_key)
     #     found_nodes = yield self.listNodes(service, profile=client.profile)
     #     d_dict = {}
     #     for publisher, node in data.items():
     #         if node not in found_nodes:
     #             log.debug(u"Skip the items retrieval for [{node}]: node doesn't exist".format(node=node))
     #             continue  # avoid pubsub "item-not-found" error
-    #         d_dict[publisher] = self.getItems(service, node, max_items, None, sub_id, rsm, client.profile)
+    #         d_dict[publisher] = self.get_items(service, node, max_items, None, sub_id, rsm, client.profile)
     #     defer.returnValue(d_dict)
 
     def getOptions(self, service, nodeIdentifier, subscriber, subscriptionIdentifier=None,
                    profile_key=C.PROF_KEY_NONE):
-        client = self.host.getClient(profile_key)
+        client = self.host.get_client(profile_key)
         return client.pubsub_client.getOptions(
             service, nodeIdentifier, subscriber, subscriptionIdentifier
         )
 
     def setOptions(self, service, nodeIdentifier, subscriber, options,
                    subscriptionIdentifier=None, profile_key=C.PROF_KEY_NONE):
-        client = self.host.getClient(profile_key)
+        client = self.host.get_client(profile_key)
         return client.pubsub_client.setOptions(
             service, nodeIdentifier, subscriber, options, subscriptionIdentifier
         )
 
-    def _createNode(self, service_s, nodeIdentifier, options, profile_key):
-        client = self.host.getClient(profile_key)
+    def _create_node(self, service_s, nodeIdentifier, options, profile_key):
+        client = self.host.get_client(profile_key)
         return self.createNode(
             client, jid.JID(service_s) if service_s else None, nodeIdentifier, options
         )
@@ -924,7 +924,7 @@
         return client.pubsub_client.createNode(service, nodeIdentifier, options)
 
     @defer.inlineCallbacks
-    def createIfNewNode(self, client, service, nodeIdentifier, options=None):
+    def create_if_new_node(self, client, service, nodeIdentifier, options=None):
         """Helper method similar to createNode, but will not fail in case of conflict"""
         try:
             yield self.createNode(client, service, nodeIdentifier, options)
@@ -934,8 +934,8 @@
             else:
                 raise e
 
-    def _getNodeConfiguration(self, service_s, nodeIdentifier, profile_key):
-        client = self.host.getClient(profile_key)
+    def _get_node_configuration(self, service_s, nodeIdentifier, profile_key):
+        client = self.host.get_client(profile_key)
         d = self.getConfiguration(
             client, jid.JID(service_s) if service_s else None, nodeIdentifier
         )
@@ -969,8 +969,8 @@
         form.makeFields(options)
         return form
 
-    def _setNodeConfiguration(self, service_s, nodeIdentifier, options, profile_key):
-        client = self.host.getClient(profile_key)
+    def _set_node_configuration(self, service_s, nodeIdentifier, options, profile_key):
+        client = self.host.get_client(profile_key)
         d = self.setConfiguration(
             client, jid.JID(service_s) if service_s else None, nodeIdentifier, options
         )
@@ -987,14 +987,14 @@
         d = request.send(client.xmlstream)
         return d
 
-    def _getAffiliations(self, service_s, nodeIdentifier, profile_key):
-        client = self.host.getClient(profile_key)
-        d = self.getAffiliations(
+    def _get_affiliations(self, service_s, nodeIdentifier, profile_key):
+        client = self.host.get_client(profile_key)
+        d = self.get_affiliations(
             client, jid.JID(service_s) if service_s else None, nodeIdentifier or None
         )
         return d
 
-    def getAffiliations(self, client, service, nodeIdentifier=None):
+    def get_affiliations(self, client, service, nodeIdentifier=None):
         """Retrieve affiliations of an entity
 
         @param nodeIdentifier(unicode, None): node to get affiliation from
@@ -1031,9 +1031,9 @@
         d.addCallback(cb)
         return d
 
-    def _getNodeAffiliations(self, service_s, nodeIdentifier, profile_key):
-        client = self.host.getClient(profile_key)
-        d = self.getNodeAffiliations(
+    def _get_node_affiliations(self, service_s, nodeIdentifier, profile_key):
+        client = self.host.get_client(profile_key)
+        d = self.get_node_affiliations(
             client, jid.JID(service_s) if service_s else None, nodeIdentifier
         )
         d.addCallback(
@@ -1041,7 +1041,7 @@
         )
         return d
 
-    def getNodeAffiliations(self, client, service, nodeIdentifier):
+    def get_node_affiliations(self, client, service, nodeIdentifier):
         """Retrieve affiliations of a node owned by profile"""
         request = pubsub.PubSubRequest("affiliationsGet")
         request.recipient = service
@@ -1076,14 +1076,14 @@
         d.addCallback(cb)
         return d
 
-    def _setNodeAffiliations(
+    def _set_node_affiliations(
         self, service_s, nodeIdentifier, affiliations, profile_key=C.PROF_KEY_NONE
     ):
-        client = self.host.getClient(profile_key)
+        client = self.host.get_client(profile_key)
         affiliations = {
             jid.JID(jid_): affiliation for jid_, affiliation in affiliations.items()
         }
-        d = self.setNodeAffiliations(
+        d = self.set_node_affiliations(
             client,
             jid.JID(service_s) if service_s else None,
             nodeIdentifier,
@@ -1091,7 +1091,7 @@
         )
         return d
 
-    def setNodeAffiliations(self, client, service, nodeIdentifier, affiliations):
+    def set_node_affiliations(self, client, service, nodeIdentifier, affiliations):
         """Update affiliations of a node owned by profile
 
         @param affiliations(dict[jid.JID, unicode]): affiliations to set
@@ -1104,17 +1104,17 @@
         d = request.send(client.xmlstream)
         return d
 
-    def _purgeNode(self, service_s, nodeIdentifier, profile_key):
-        client = self.host.getClient(profile_key)
-        return self.purgeNode(
+    def _purge_node(self, service_s, nodeIdentifier, profile_key):
+        client = self.host.get_client(profile_key)
+        return self.purge_node(
             client, jid.JID(service_s) if service_s else None, nodeIdentifier
         )
 
-    def purgeNode(self, client, service, nodeIdentifier):
-        return client.pubsub_client.purgeNode(service, nodeIdentifier)
+    def purge_node(self, client, service, nodeIdentifier):
+        return client.pubsub_client.purge_node(service, nodeIdentifier)
 
-    def _deleteNode(self, service_s, nodeIdentifier, profile_key):
-        client = self.host.getClient(profile_key)
+    def _delete_node(self, service_s, nodeIdentifier, profile_key):
+        client = self.host.get_client(profile_key)
         return self.deleteNode(
             client, jid.JID(service_s) if service_s else None, nodeIdentifier
         )
@@ -1132,31 +1132,31 @@
 
         This method should only be called from bridge
         """
-        client = self.host.getClient(profile_key)
+        client = self.host.get_client(profile_key)
         service = jid.JID(service_s) if service_s else client.jid.userhostJID()
         client.pubsub_watching.add((service, node))
 
-    def _removeWatch(self, service_s, node, profile_key):
+    def _remove_watch(self, service_s, node, profile_key):
         """remove a node watch
 
         This method should only be called from bridge
         """
-        client = self.host.getClient(profile_key)
+        client = self.host.get_client(profile_key)
         service = jid.JID(service_s) if service_s else client.jid.userhostJID()
         client.pubsub_watching.remove((service, node))
 
-    def _retractItem(
+    def _retract_item(
         self, service_s, nodeIdentifier, itemIdentifier, notify, profile_key
     ):
-        return self._retractItems(
+        return self._retract_items(
             service_s, nodeIdentifier, (itemIdentifier,), notify, profile_key
         )
 
-    def _retractItems(
+    def _retract_items(
         self, service_s, nodeIdentifier, itemIdentifiers, notify, profile_key
     ):
-        client = self.host.getClient(profile_key)
-        return self.retractItems(
+        client = self.host.get_client(profile_key)
+        return self.retract_items(
             client,
             jid.JID(service_s) if service_s else None,
             nodeIdentifier,
@@ -1164,7 +1164,7 @@
             notify,
         )
 
-    def retractItems(
+    def retract_items(
         self,
         client: SatXMPPClient,
         service: jid.JID,
@@ -1176,7 +1176,7 @@
             service, nodeIdentifier, itemIdentifiers, notify=notify
         )
 
-    def _renameItem(
+    def _rename_item(
         self,
         service,
         node,
@@ -1184,13 +1184,13 @@
         new_id,
         profile_key=C.PROF_KEY_NONE,
     ):
-        client = self.host.getClient(profile_key)
+        client = self.host.get_client(profile_key)
         service = jid.JID(service) if service else None
-        return defer.ensureDeferred(self.renameItem(
+        return defer.ensureDeferred(self.rename_item(
             client, service, node, item_id, new_id
         ))
 
-    async def renameItem(
+    async def rename_item(
         self,
         client: SatXMPPEntity,
         service: Optional[jid.JID],
@@ -1207,12 +1207,12 @@
             raise ValueError("item_id and new_id must not be empty")
         # retract must be done last, so if something goes wrong, the exception will stop
         # the workflow and no accidental delete should happen
-        item_elt = (await self.getItems(client, service, node, item_ids=[item_id]))[0][0]
-        await self.sendItem(client, service, node, item_elt.firstChildElement(), new_id)
-        await self.retractItems(client, service, node, [item_id])
+        item_elt = (await self.get_items(client, service, node, item_ids=[item_id]))[0][0]
+        await self.send_item(client, service, node, item_elt.firstChildElement(), new_id)
+        await self.retract_items(client, service, node, [item_id])
 
     def _subscribe(self, service, nodeIdentifier, options, profile_key=C.PROF_KEY_NONE):
-        client = self.host.getClient(profile_key)
+        client = self.host.get_client(profile_key)
         service = None if not service else jid.JID(service)
         d = defer.ensureDeferred(
             self.subscribe(
@@ -1236,7 +1236,7 @@
         # TODO: reimplement a subscribtion cache, checking that we have not subscription before trying to subscribe
         if service is None:
             service = client.jid.userhostJID()
-        cont, trigger_sub = await self.host.trigger.asyncReturnPoint(
+        cont, trigger_sub = await self.host.trigger.async_return_point(
             "XEP-0060_subscribe", client, service, nodeIdentifier, sub_jid, options,
         )
         if not cont:
@@ -1254,7 +1254,7 @@
         return subscription
 
     def _unsubscribe(self, service, nodeIdentifier, profile_key=C.PROF_KEY_NONE):
-        client = self.host.getClient(profile_key)
+        client = self.host.get_client(profile_key)
         service = None if not service else jid.JID(service)
         return defer.ensureDeferred(self.unsubscribe(client, service, nodeIdentifier))
 
@@ -1267,7 +1267,7 @@
         subscriptionIdentifier: Optional[str] = None,
         sender: Optional[jid.JID] = None,
     ) -> None:
-        if not await self.host.trigger.asyncPoint(
+        if not await self.host.trigger.async_point(
             "XEP-0060_unsubscribe", client, service, nodeIdentifier, sub_jid,
             subscriptionIdentifier, sender
         ):
@@ -1298,7 +1298,7 @@
         nodeIdentifier="",
         profile_key=C.PROF_KEY_NONE
     ) -> str:
-        client = self.host.getClient(profile_key)
+        client = self.host.get_client(profile_key)
         service = None if not service else jid.JID(service)
         subs = await self.subscriptions(client, service, nodeIdentifier or None)
         return data_format.serialise(subs)
@@ -1315,7 +1315,7 @@
         @param nodeIdentifier(unicode, None): node to check
             None to get all subscriptions
         """
-        cont, ret = await self.host.trigger.asyncReturnPoint(
+        cont, ret = await self.host.trigger.async_return_point(
             "XEP-0060_subscriptions", client, service, node
         )
         if not cont:
@@ -1336,7 +1336,7 @@
 
     ## misc tools ##
 
-    def getNodeURI(self, service, node, item=None):
+    def get_node_uri(self, service, node, item=None):
         """Return XMPP URI of a PubSub node
 
         @param service(jid.JID): PubSub service
@@ -1359,17 +1359,17 @@
 
     # generic #
 
-    def getRTResults(
+    def get_rt_results(
         self, session_id, on_success=None, on_error=None, profile=C.PROF_KEY_NONE
     ):
-        return self.rt_sessions.getResults(session_id, on_success, on_error, profile)
+        return self.rt_sessions.get_results(session_id, on_success, on_error, profile)
 
-    def transItemsData(self, items_data, item_cb=lambda item: item.toXml()):
-        """Helper method to transform result from [getItems]
+    def trans_items_data(self, items_data, item_cb=lambda item: item.toXml()):
+        """Helper method to transform result from [get_items]
 
         the items_data must be a tuple(list[domish.Element], dict[unicode, unicode])
-        as returned by [getItems].
-        @param items_data(tuple): tuple returned by [getItems]
+        as returned by [get_items].
+        @param items_data(tuple): tuple returned by [get_items]
         @param item_cb(callable): method to transform each item
         @return (tuple): a serialised form ready to go throught bridge
         """
@@ -1378,15 +1378,15 @@
 
         return (items, metadata)
 
-    def transItemsDataD(self, items_data, item_cb):
-        """Helper method to transform result from [getItems], deferred version
+    def trans_items_data_d(self, items_data, item_cb):
+        """Helper method to transform result from [get_items], deferred version
 
         the items_data must be a tuple(list[domish.Element], dict[unicode, unicode])
-        as returned by [getItems]. metadata values are then casted to unicode and
+        as returned by [get_items]. metadata values are then casted to unicode and
         each item is passed to items_cb.
         An errback is added to item_cb, and when it is fired the value is filtered from
             final items
-        @param items_data(tuple): tuple returned by [getItems]
+        @param items_data(tuple): tuple returned by [get_items]
         @param item_cb(callable): method to transform each item (must return a deferred)
         @return (tuple): a deferred which fire a dict which can be serialised to go
             throught bridge
@@ -1403,7 +1403,7 @@
         ))
         return d
 
-    def serDList(self, results, failure_result=None):
+    def ser_d_list(self, results, failure_result=None):
         """Serialise a DeferredList result
 
         @param results: DeferredList results
@@ -1425,19 +1425,19 @@
     # subscribe #
 
     @utils.ensure_deferred
-    async def _getNodeSubscriptions(
+    async def _get_node_subscriptions(
         self,
         service: str,
         node: str,
         profile_key: str
     ) -> Dict[str, str]:
-        client = self.host.getClient(profile_key)
-        subs = await self.getNodeSubscriptions(
+        client = self.host.get_client(profile_key)
+        subs = await self.get_node_subscriptions(
             client, jid.JID(service) if service else None, node
         )
         return {j.full(): a for j, a in subs.items()}
 
-    async def getNodeSubscriptions(
+    async def get_node_subscriptions(
         self,
         client: SatXMPPEntity,
         service: Optional[jid.JID],
@@ -1480,15 +1480,15 @@
                 )
             )
 
-    def _setNodeSubscriptions(
+    def _set_node_subscriptions(
         self, service_s, nodeIdentifier, subscriptions, profile_key=C.PROF_KEY_NONE
     ):
-        client = self.host.getClient(profile_key)
+        client = self.host.get_client(profile_key)
         subscriptions = {
             jid.JID(jid_): subscription
             for jid_, subscription in subscriptions.items()
         }
-        d = self.setNodeSubscriptions(
+        d = self.set_node_subscriptions(
             client,
             jid.JID(service_s) if service_s else None,
             nodeIdentifier,
@@ -1496,7 +1496,7 @@
         )
         return d
 
-    def setNodeSubscriptions(self, client, service, nodeIdentifier, subscriptions):
+    def set_node_subscriptions(self, client, service, nodeIdentifier, subscriptions):
         """Set or update subscriptions of a node owned by profile
 
         @param subscriptions(dict[jid.JID, unicode]): subscriptions to set
@@ -1512,7 +1512,7 @@
         d = request.send(client.xmlstream)
         return d
 
-    def _manySubscribeRTResult(self, session_id, profile_key=C.PROF_KEY_DEFAULT):
+    def _many_subscribe_rt_result(self, session_id, profile_key=C.PROF_KEY_DEFAULT):
         """Get real-time results for subcribeToManu session
 
         @param session_id: id of the real-time deferred session
@@ -1524,8 +1524,8 @@
                 - failure(unicode): empty string in case of success, error message else
         @param profile_key: %(doc_profile_key)s
         """
-        profile = self.host.getClient(profile_key).profile
-        d = self.rt_sessions.getResults(
+        profile = self.host.get_client(profile_key).profile
+        d = self.rt_sessions.get_results(
             session_id,
             on_success=lambda result: "",
             on_error=lambda failure: str(failure.value),
@@ -1543,17 +1543,17 @@
         )
         return d
 
-    def _subscribeToMany(
+    def _subscribe_to_many(
         self, node_data, subscriber=None, options=None, profile_key=C.PROF_KEY_NONE
     ):
-        return self.subscribeToMany(
+        return self.subscribe_to_many(
             [(jid.JID(service), str(node)) for service, node in node_data],
             jid.JID(subscriber),
             options,
             profile_key,
         )
 
-    def subscribeToMany(
+    def subscribe_to_many(
         self, node_data, subscriber, options=None, profile_key=C.PROF_KEY_NONE
     ):
         """Subscribe to several nodes at once.
@@ -1566,7 +1566,7 @@
         @param profile_key (str): %(doc_profile_key)s
         @return (str): RT Deferred session id
         """
-        client = self.host.getClient(profile_key)
+        client = self.host.get_client(profile_key)
         deferreds = {}
         for service, node in node_data:
             deferreds[(service, node)] = defer.ensureDeferred(
@@ -1574,7 +1574,7 @@
                     service, node, subscriber, options=options
                 )
             )
-        return self.rt_sessions.newSession(deferreds, client.profile)
+        return self.rt_sessions.new_session(deferreds, client.profile)
         # found_nodes = yield self.listNodes(service, profile=client.profile)
         # subscribed_nodes = yield self.listSubscribedNodes(service, profile=client.profile)
         # d_list = []
@@ -1587,8 +1587,8 @@
 
     # get #
 
-    def _getFromManyRTResult(self, session_id, profile_key=C.PROF_KEY_DEFAULT):
-        """Get real-time results for getFromMany session
+    def _get_from_many_rt_result(self, session_id, profile_key=C.PROF_KEY_DEFAULT):
+        """Get real-time results for get_from_many session
 
         @param session_id: id of the real-time deferred session
         @param profile_key: %(doc_profile_key)s
@@ -1601,10 +1601,10 @@
                 - items (list[s]): raw XML of items
                 - metadata(dict): serialised metadata
         """
-        profile = self.host.getClient(profile_key).profile
-        d = self.rt_sessions.getResults(
+        profile = self.host.get_client(profile_key).profile
+        d = self.rt_sessions.get_results(
             session_id,
-            on_success=lambda result: ("", self.transItemsData(result)),
+            on_success=lambda result: ("", self.trans_items_data(result)),
             on_error=lambda failure: (str(failure.value) or UNSPECIFIED, ([], {})),
             profile=profile,
         )
@@ -1621,15 +1621,15 @@
         )
         return d
 
-    def _getFromMany(
+    def _get_from_many(
         self, node_data, max_item=10, extra="", profile_key=C.PROF_KEY_NONE
     ):
         """
         @param max_item(int): maximum number of item to get, C.NO_LIMIT for no limit
         """
         max_item = None if max_item == C.NO_LIMIT else max_item
-        extra = self.parseExtra(data_format.deserialise(extra))
-        return self.getFromMany(
+        extra = self.parse_extra(data_format.deserialise(extra))
+        return self.get_from_many(
             [(jid.JID(service), str(node)) for service, node in node_data],
             max_item,
             extra.rsm_request,
@@ -1637,7 +1637,7 @@
             profile_key,
         )
 
-    def getFromMany(self, node_data, max_item=None, rsm_request=None, extra=None,
+    def get_from_many(self, node_data, max_item=None, rsm_request=None, extra=None,
                     profile_key=C.PROF_KEY_NONE):
         """Get items from many nodes at once
 
@@ -1649,13 +1649,13 @@
         @param profile_key (unicode): %(doc_profile_key)s
         @return (str): RT Deferred session id
         """
-        client = self.host.getClient(profile_key)
+        client = self.host.get_client(profile_key)
         deferreds = {}
         for service, node in node_data:
-            deferreds[(service, node)] = defer.ensureDeferred(self.getItems(
+            deferreds[(service, node)] = defer.ensureDeferred(self.get_items(
                 client, service, node, max_item, rsm_request=rsm_request, extra=extra
             ))
-        return self.rt_sessions.newSession(deferreds, client.profile)
+        return self.rt_sessions.new_session(deferreds, client.profile)
 
 
 @implementer(disco.IDisco)
@@ -1689,13 +1689,13 @@
         )
         # items must be returned, thus this async point can't stop the workflow (but it
         # can modify returned items)
-        await self.host.trigger.asyncPoint(
+        await self.host.trigger.async_point(
             "XEP-0060_items", self.parent, service, nodeIdentifier, items, rsm_response,
             extra
         )
         return items, rsm_response
 
-    def _getNodeCallbacks(self, node, event):
+    def _get_node_callbacks(self, node, event):
         """Generate callbacks from given node and event
 
         @param node(unicode): node used for the item
@@ -1712,16 +1712,16 @@
             except KeyError:
                 continue
 
-    async def _callNodeCallbacks(self, client, event: pubsub.ItemsEvent) -> None:
+    async def _call_node_callbacks(self, client, event: pubsub.ItemsEvent) -> None:
         """Call sequencially event callbacks of a node
 
         Callbacks are called sequencially and not in parallel to be sure to respect
         priority (notably for plugin needing to get old items before they are modified or
         deleted from cache).
         """
-        for callback in self._getNodeCallbacks(event.nodeIdentifier, C.PS_ITEMS):
+        for callback in self._get_node_callbacks(event.nodeIdentifier, C.PS_ITEMS):
             try:
-                await utils.asDeferred(callback, client, event)
+                await utils.as_deferred(callback, client, event)
             except Exception as e:
                 log.error(
                     f"Error while running items event callback {callback}: {e}"
@@ -1730,10 +1730,10 @@
     def itemsReceived(self, event):
         log.debug("Pubsub items received")
         client = self.parent
-        defer.ensureDeferred(self._callNodeCallbacks(client, event))
+        defer.ensureDeferred(self._call_node_callbacks(client, event))
         if (event.sender, event.nodeIdentifier) in client.pubsub_watching:
             raw_items = [i.toXml() for i in event.items]
-            self.host.bridge.psEventRaw(
+            self.host.bridge.ps_event_raw(
                 event.sender.full(),
                 event.nodeIdentifier,
                 C.PS_ITEMS,
@@ -1743,27 +1743,27 @@
 
     def deleteReceived(self, event):
         log.debug(("Publish node deleted"))
-        for callback in self._getNodeCallbacks(event.nodeIdentifier, C.PS_DELETE):
-            d = utils.asDeferred(callback, self.parent, event)
+        for callback in self._get_node_callbacks(event.nodeIdentifier, C.PS_DELETE):
+            d = utils.as_deferred(callback, self.parent, event)
             d.addErrback(lambda f: log.error(
                 f"Error while running delete event callback {callback}: {f}"
             ))
         client = self.parent
         if (event.sender, event.nodeIdentifier) in client.pubsub_watching:
-            self.host.bridge.psEventRaw(
+            self.host.bridge.ps_event_raw(
                 event.sender.full(), event.nodeIdentifier, C.PS_DELETE, [], client.profile
             )
 
     def purgeReceived(self, event):
         log.debug(("Publish node purged"))
-        for callback in self._getNodeCallbacks(event.nodeIdentifier, C.PS_PURGE):
-            d = utils.asDeferred(callback, self.parent, event)
+        for callback in self._get_node_callbacks(event.nodeIdentifier, C.PS_PURGE):
+            d = utils.as_deferred(callback, self.parent, event)
             d.addErrback(lambda f: log.error(
                 f"Error while running purge event callback {callback}: {f}"
             ))
         client = self.parent
         if (event.sender, event.nodeIdentifier) in client.pubsub_watching:
-            self.host.bridge.psEventRaw(
+            self.host.bridge.ps_event_raw(
                 event.sender.full(), event.nodeIdentifier, C.PS_PURGE, [], client.profile
             )
 
@@ -1798,7 +1798,7 @@
 
         return d.addCallback(cb)
 
-    def purgeNode(self, service, nodeIdentifier):
+    def purge_node(self, service, nodeIdentifier):
         """Purge a node (i.e. delete all items from it)
 
         @param service(jid.JID, None): service to send the item to