Mercurial > libervia-backend
diff sat_frontends/quick_frontend/quick_games.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 | be6d91572633 |
children | 4b842c1fb686 |
line wrap: on
line diff
--- a/sat_frontends/quick_frontend/quick_games.py Fri Apr 07 15:18:39 2023 +0200 +++ b/sat_frontends/quick_frontend/quick_games.py Sat Apr 08 13:54:42 2023 +0200 @@ -36,26 +36,26 @@ _signal_suffixes = None @classmethod - def registerSignals(cls, host): + def register_signals(cls, host): def make_handler(suffix, signal): def handler(*args): if suffix in ("Started", "Players"): - return cls.startedHandler(host, suffix, *args) - return cls.genericHandler(host, signal, *args) + return cls.started_handler(host, suffix, *args) + return cls.generic_handler(host, signal, *args) return handler for suffix in cls._signal_suffixes: signal = cls._signal_prefix + suffix - host.registerSignal( + host.register_signal( signal, handler=make_handler(suffix, signal), iface="plugin" ) @classmethod - def startedHandler(cls, host, suffix, *args): + def started_handler(cls, host, suffix, *args): room_jid, args, profile = jid.JID(args[0]), args[1:-1], args[-1] referee, players, args = args[0], args[1], args[2:] - chat_widget = host.widgets.getOrCreateWidget( + chat_widget = host.widgets.get_or_create_widget( quick_chat.QuickChat, room_jid, type_=C.CHAT_GROUP, profile=profile ) @@ -66,8 +66,8 @@ index = 0 contact_list = host.contact_lists[profile] for occupant in chat_widget.occupants: - occupant_jid = jid.newResource(room_jid, occupant) - contact_list.setCache( + occupant_jid = jid.new_resource(room_jid, occupant) + contact_list.set_cache( occupant_jid, cls._game_name, symbols[index % len(symbols)] if occupant in players else None, @@ -78,9 +78,9 @@ return # waiting for other players to join, or not playing if cls._game_name in chat_widget.games: return # game panel is already there - real_class = host.widgets.getRealClass(cls) + real_class = host.widgets.get_real_class(cls) if real_class == cls: - host.showDialog( + host.show_dialog( _( "A {game} activity between {players} has been started, but you couldn't take part because your client doesn't support it." ).format(game=cls._game_name, players=", ".join(players)), @@ -89,12 +89,12 @@ return panel = real_class(chat_widget, referee, players, *args) chat_widget.games[cls._game_name] = panel - chat_widget.addGamePanel(panel) + chat_widget.add_game_panel(panel) @classmethod - def genericHandler(cls, host, signal, *args): + def generic_handler(cls, host, signal, *args): room_jid, args, profile = jid.JID(args[0]), args[1:-1], args[-1] - chat_widget = host.widgets.getWidget(quick_chat.QuickChat, room_jid, profile) + chat_widget = host.widgets.get_widget(quick_chat.QuickChat, room_jid, profile) if chat_widget: try: game_panel = chat_widget.games[cls._game_name]