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
|
|
@ -48,7 +48,7 @@ class FakeMUCClient(object):
|
|||
@param profile_key: the profile key of the user joining the room
|
||||
@return: the deferred joined wokkel.muc.Room instance
|
||||
"""
|
||||
profile = self.host.memory.getProfileName(profile_key)
|
||||
profile = self.host.memory.get_profile_name(profile_key)
|
||||
roster = {}
|
||||
|
||||
# ask the other profiles to fill our roster
|
||||
|
|
@ -101,7 +101,7 @@ class FakeMUCClient(object):
|
|||
@param profile_key: the profile key of the user joining the room
|
||||
@return: a dummy deferred
|
||||
"""
|
||||
profile = self.host.memory.getProfileName(profile_key)
|
||||
profile = self.host.memory.get_profile_name(profile_key)
|
||||
room = self.joined_rooms[roomJID]
|
||||
# remove ourself from the other rosters
|
||||
for i in range(0, len(C.PROFILE)):
|
||||
|
|
@ -134,20 +134,20 @@ class FakeXEP_0045(plugin_xep_0045.XEP_0045):
|
|||
@param profile_key: the profile of the user joining the room
|
||||
@return: the deferred joined wokkel.muc.Room instance or None
|
||||
"""
|
||||
profile = self.host.memory.getProfileName(profile_key)
|
||||
profile = self.host.memory.get_profile_name(profile_key)
|
||||
if room_jid in self.clients[profile].joined_rooms:
|
||||
return defer.succeed(None)
|
||||
room = self.clients[profile].join(room_jid, nick, profile_key=profile)
|
||||
return room
|
||||
|
||||
def joinRoom(self, muc_index, user_index):
|
||||
def join_room(self, muc_index, user_index):
|
||||
"""Called by tests
|
||||
@return: the nickname of the user who joined room"""
|
||||
muc_jid = C.MUC[muc_index]
|
||||
nick = C.JID[user_index].user
|
||||
profile = C.PROFILE[user_index]
|
||||
self.join(muc_jid, nick, profile_key=profile)
|
||||
return self.getNick(muc_index, user_index)
|
||||
return self.get_nick(muc_index, user_index)
|
||||
|
||||
def leave(self, room_jid, profile_key="@DEFAULT@"):
|
||||
"""
|
||||
|
|
@ -155,21 +155,21 @@ class FakeXEP_0045(plugin_xep_0045.XEP_0045):
|
|||
@param profile_key: the profile of the user leaving the room
|
||||
@return: a dummy deferred
|
||||
"""
|
||||
profile = self.host.memory.getProfileName(profile_key)
|
||||
profile = self.host.memory.get_profile_name(profile_key)
|
||||
if room_jid not in self.clients[profile].joined_rooms:
|
||||
raise plugin_xep_0045.UnknownRoom("This room has not been joined")
|
||||
return self.clients[profile].leave(room_jid, profile)
|
||||
|
||||
def leaveRoom(self, muc_index, user_index):
|
||||
def leave_room(self, muc_index, user_index):
|
||||
"""Called by tests
|
||||
@return: the nickname of the user who left the room"""
|
||||
muc_jid = C.MUC[muc_index]
|
||||
nick = self.getNick(muc_index, user_index)
|
||||
nick = self.get_nick(muc_index, user_index)
|
||||
profile = C.PROFILE[user_index]
|
||||
self.leave(muc_jid, profile_key=profile)
|
||||
return nick
|
||||
|
||||
def getRoom(self, muc_index, user_index):
|
||||
def get_room(self, muc_index, user_index):
|
||||
"""Called by tests
|
||||
@return: a wokkel.muc.Room instance"""
|
||||
profile = C.PROFILE[user_index]
|
||||
|
|
@ -179,13 +179,13 @@ class FakeXEP_0045(plugin_xep_0045.XEP_0045):
|
|||
except (AttributeError, KeyError):
|
||||
return None
|
||||
|
||||
def getNick(self, muc_index, user_index):
|
||||
def get_nick(self, muc_index, user_index):
|
||||
try:
|
||||
return self.getRoomNick(C.MUC[muc_index], C.PROFILE[user_index])
|
||||
return self.get_room_nick(C.MUC[muc_index], C.PROFILE[user_index])
|
||||
except (KeyError, AttributeError):
|
||||
return ""
|
||||
|
||||
def getNickOfUser(self, muc_index, user_index, profile_index, secure=True):
|
||||
def get_nick_of_user(self, muc_index, user_index, profile_index, secure=True):
|
||||
try:
|
||||
room = self.clients[C.PROFILE[profile_index]].joined_rooms[C.MUC[muc_index]]
|
||||
return self.getRoomNickOfUser(room, C.JID[user_index])
|
||||
|
|
@ -200,7 +200,7 @@ class FakeXEP_0249(object):
|
|||
def invite(self, target, room, options={}, profile_key="@DEFAULT@"):
|
||||
"""
|
||||
Invite a user to a room. To accept the invitation from a test,
|
||||
just call FakeXEP_0045.joinRoom (no need to have a dedicated method).
|
||||
just call FakeXEP_0045.join_room (no need to have a dedicated method).
|
||||
@param target: jid of the user to invite
|
||||
@param room: jid of the room where the user is invited
|
||||
@options: attribute with extra info (reason, password) as in #XEP-0249
|
||||
|
|
@ -278,13 +278,13 @@ class FakeSatPubSubClient(object):
|
|||
self.__rsm_responses[ext_data["id"]] = RSMResponse(len(items), *args)
|
||||
return defer.succeed(items)
|
||||
|
||||
def retractItems(self, service, nodeIdentifier, itemIdentifiers, sender=None):
|
||||
def retract_items(self, service, nodeIdentifier, itemIdentifiers, sender=None):
|
||||
node = self.__items[nodeIdentifier]
|
||||
for item in [item for item in node if item["id"] in itemIdentifiers]:
|
||||
node.remove(item)
|
||||
return defer.succeed(None)
|
||||
|
||||
def getRSMResponse(self, id):
|
||||
def get_rsm_response(self, id):
|
||||
if id not in self.__rsm_responses:
|
||||
return {}
|
||||
result = self.__rsm_responses[id].toDict()
|
||||
|
|
@ -294,7 +294,7 @@ class FakeSatPubSubClient(object):
|
|||
def subscriptions(self, service, nodeIdentifier, sender=None):
|
||||
return defer.succeed([])
|
||||
|
||||
def service_getDiscoItems(self, service, nodeIdentifier, profile_key=C.PROF_KEY_NONE):
|
||||
def service_get_disco_items(self, service, nodeIdentifier, profile_key=C.PROF_KEY_NONE):
|
||||
items = DiscoItems()
|
||||
for item in list(self.__items.keys()):
|
||||
items.append(DiscoItem(service, item))
|
||||
|
|
|
|||
Loading…
Reference in a new issue