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:
Goffi 2023-04-08 13:54:42 +02:00
commit 6a6f15707a

View file

@ -167,7 +167,7 @@ class XEP_groupblogTest(helpers.SatTestCase):
def _initialise(self, profile_key):
profile = profile_key
client = self.host.getClient(profile)
client = self.host.get_client(profile)
if not self.__initialised:
client.item_access_pubsub = jid.JID(SERVICE)
xep_0060 = self.host.plugins["XEP-0060"]
@ -176,15 +176,15 @@ class XEP_groupblogTest(helpers.SatTestCase):
)
client.pubsub_client.parent = client
self.psclient = client.pubsub_client
helpers.FakeSAT.getDiscoItems = self.psclient.service_getDiscoItems
helpers.FakeSAT.getDiscoItems = self.psclient.service_get_disco_items
self.__initialised = True
return defer.succeed((profile, client))
def _addItem(self, profile, item, parent_node=None):
client = self.host.getClient(profile)
client.pubsub_client._addItem(item, parent_node)
def _add_item(self, profile, item, parent_node=None):
client = self.host.get_client(profile)
client.pubsub_client._add_item(item, parent_node)
def test_sendGroupBlog(self):
def test_send_group_blog(self):
self._initialise(C.PROFILE[0])
d = self.psclient.items(SERVICE, NODE_ID)
d.addCallback(lambda items: self.assertEqual(len(items), 0))
@ -196,9 +196,9 @@ class XEP_groupblogTest(helpers.SatTestCase):
d.addCallback(lambda __: self.psclient.items(SERVICE, NODE_ID))
return d.addCallback(lambda items: self.assertEqual(len(items), 1))
def test_deleteGroupBlog(self):
def test_delete_group_blog(self):
pub_data = (SERVICE, NODE_ID, ITEM_ID_1)
self.host.bridge.expectCall(
self.host.bridge.expect_call(
"personalEvent",
C.JID_STR[0],
"MICROBLOG_DELETE",
@ -214,7 +214,7 @@ class XEP_groupblogTest(helpers.SatTestCase):
)
return d.addCallback(self.assertEqual, None)
def test_updateGroupBlog(self):
def test_update_group_blog(self):
pub_data = (SERVICE, NODE_ID, ITEM_ID_1)
new_text = "silfu23RFWUP)IWNOEIOEFÖ"
@ -232,7 +232,7 @@ class XEP_groupblogTest(helpers.SatTestCase):
)
)
def test_sendGroupBlogComment(self):
def test_send_group_blog_comment(self):
self._initialise(C.PROFILE[0])
d = self.psclient.items(SERVICE, NODE_ID)
d.addCallback(lambda items: self.assertEqual(len(items), 0))
@ -244,7 +244,7 @@ class XEP_groupblogTest(helpers.SatTestCase):
d.addCallback(lambda __: self.psclient.items(SERVICE, COMMENTS_NODE_ID_1))
return d.addCallback(lambda items: self.assertEqual(len(items), 1))
def test_getGroupBlogs(self):
def test_get_group_blogs(self):
self._initialise(C.PROFILE[0])
d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
d.addCallback(
@ -256,7 +256,7 @@ class XEP_groupblogTest(helpers.SatTestCase):
)
return d.addCallback(self.assertEqual, result)
def test_getGroupBlogsNoCount(self):
def test_get_group_blogs_no_count(self):
self._initialise(C.PROFILE[0])
d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
d.addCallback(
@ -270,7 +270,7 @@ class XEP_groupblogTest(helpers.SatTestCase):
)
return d.addCallback(self.assertEqual, result)
def test_getGroupBlogsWithIDs(self):
def test_get_group_blogs_with_i_ds(self):
self._initialise(C.PROFILE[0])
d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
d.addCallback(
@ -284,7 +284,7 @@ class XEP_groupblogTest(helpers.SatTestCase):
)
return d.addCallback(self.assertEqual, result)
def test_getGroupBlogsWithRSM(self):
def test_get_group_blogs_with_rsm(self):
self._initialise(C.PROFILE[0])
d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
d.addCallback(
@ -298,7 +298,7 @@ class XEP_groupblogTest(helpers.SatTestCase):
)
return d.addCallback(self.assertEqual, result)
def test_getGroupBlogsWithComments(self):
def test_get_group_blogs_with_comments(self):
self._initialise(C.PROFILE[0])
d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
d.addCallback(
@ -328,7 +328,7 @@ class XEP_groupblogTest(helpers.SatTestCase):
)
return d.addCallback(self.assertEqual, result)
def test_getGroupBlogsWithComments2(self):
def test_get_group_blogs_with_comments_2(self):
self._initialise(C.PROFILE[0])
d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
d.addCallback(
@ -361,7 +361,7 @@ class XEP_groupblogTest(helpers.SatTestCase):
return d.addCallback(self.assertEqual, result)
def test_getGroupBlogsAtom(self):
def test_get_group_blogs_atom(self):
self._initialise(C.PROFILE[0])
d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
d.addCallback(
@ -376,7 +376,7 @@ class XEP_groupblogTest(helpers.SatTestCase):
return d.addCallback(cb)
def test_getMassiveGroupBlogs(self):
def test_get_massive_group_blogs(self):
self._initialise(C.PROFILE[0])
d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
d.addCallback(
@ -400,7 +400,7 @@ class XEP_groupblogTest(helpers.SatTestCase):
d.addCallback(clean)
d.addCallback(self.assertEqual, result)
def test_getMassiveGroupBlogsWithComments(self):
def test_get_massive_group_blogs_with_comments(self):
self._initialise(C.PROFILE[0])
d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
d.addCallback(
@ -429,7 +429,7 @@ class XEP_groupblogTest(helpers.SatTestCase):
d.addCallback(clean)
d.addCallback(self.assertEqual, result)
def test_getGroupBlogComments(self):
def test_get_group_blog_comments(self):
self._initialise(C.PROFILE[0])
d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
d.addCallback(
@ -446,12 +446,12 @@ class XEP_groupblogTest(helpers.SatTestCase):
)
return d.addCallback(self.assertEqual, result)
def test_subscribeGroupBlog(self):
def test_subscribe_group_blog(self):
self._initialise(C.PROFILE[0])
d = self.plugin.subscribeGroupBlog(PUBLISHER, profile_key=C.PROFILE[0])
return d.addCallback(self.assertEqual, None)
def test_massiveSubscribeGroupBlogs(self):
def test_massive_subscribe_group_blogs(self):
self._initialise(C.PROFILE[0])
d = self.plugin.massiveSubscribeGroupBlogs(
"JID", [jid.JID(PUBLISHER)], profile_key=C.PROFILE[0]
@ -469,10 +469,10 @@ class XEP_groupblogTest(helpers.SatTestCase):
d.addCallback(clean)
return d.addCallback(self.assertEqual, None)
def test_deleteAllGroupBlogs(self):
def test_delete_all_group_blogs(self):
"""Delete our main node and associated comments node"""
self._initialise(C.PROFILE[0])
self.host.profiles[C.PROFILE[0]].roster.addItem(jid.JID(OTHER_PUBLISHER))
self.host.profiles[C.PROFILE[0]].roster.add_item(jid.JID(OTHER_PUBLISHER))
d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
d.addCallback(
lambda __: self.psclient.publish(
@ -517,10 +517,10 @@ class XEP_groupblogTest(helpers.SatTestCase):
d.addCallback(lambda items: self.assertEqual(len(items), 2))
return d
def test_deleteAllGroupBlogsComments(self):
def test_delete_all_group_blogs_comments(self):
"""Delete the comments we posted on other node's"""
self._initialise(C.PROFILE[0])
self.host.profiles[C.PROFILE[0]].roster.addItem(jid.JID(OTHER_PUBLISHER))
self.host.profiles[C.PROFILE[0]].roster.add_item(jid.JID(OTHER_PUBLISHER))
d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
d.addCallback(
lambda __: self.psclient.publish(
@ -565,9 +565,9 @@ class XEP_groupblogTest(helpers.SatTestCase):
d.addCallback(lambda items: self.assertEqual(len(items), 0))
return d
def test_deleteAllGroupBlogsAndComments(self):
def test_delete_all_group_blogs_and_comments(self):
self._initialise(C.PROFILE[0])
self.host.profiles[C.PROFILE[0]].roster.addItem(jid.JID(OTHER_PUBLISHER))
self.host.profiles[C.PROFILE[0]].roster.add_item(jid.JID(OTHER_PUBLISHER))
d = self.psclient.publish(SERVICE, NODE_ID, [ITEM_1])
d.addCallback(
lambda __: self.psclient.publish(