diff cagou/plugins/plugin_wid_remote.py @ 491:203755bbe0fe

massive refactoring from camelCase -> snake_case. See backend commit log for more details
author Goffi <goffi@goffi.org>
date Sat, 08 Apr 2023 13:44:32 +0200
parents 3c9ba4a694ef
children 5114bbb5daa3
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_remote.py	Sat Apr 08 13:34:55 2023 +0200
+++ b/cagou/plugins/plugin_wid_remote.py	Sat Apr 08 13:44:32 2023 +0200
@@ -75,7 +75,7 @@
     def profile(self):
         return self.main_wid.profile
 
-    def updateUI(self, action_data):
+    def update_ui(self, action_data):
         xmlui_raw = action_data['xmlui']
         ui_tpl = template_xmlui.create(G.host, xmlui_raw)
         self.ui_tpl = ui_tpl
@@ -92,33 +92,33 @@
         elif playback_status == "Stopped":
             self.status = "play"
         else:
-            G.host.addNote(
+            G.host.add_note(
                 title=NOTE_TITLE,
                 message=_("Unknown playback status: playback_status")
                           .format(playback_status=playback_status),
                 level=C.XMLUI_DATA_LVL_WARNING)
         self.commands = {v:k for k,v in ui_tpl.widgets['command'].options}
 
-    def adHocRunCb(self, xmlui_raw):
+    def ad_hoc_run_cb(self, xmlui_raw):
         ui_tpl = template_xmlui.create(G.host, xmlui_raw)
         data = {xmlui.XMLUIPanel.escape("media_player"): self.remote_item.node,
                 "session_id": ui_tpl.session_id}
-        G.host.bridge.launchAction(
+        G.host.bridge.action_launch(
             ui_tpl.submit_id, data, self.profile,
-            callback=self.updateUI,
+            callback=self.update_ui,
             errback=self.main_wid.errback)
 
     def on_remote_item(self, __, remote):
         NS_MEDIA_PLAYER = G.host.ns_map["mediaplayer"]
-        G.host.bridge.adHocRun(str(remote.device_jid), NS_MEDIA_PLAYER, self.profile,
-                               callback=self.adHocRunCb,
+        G.host.bridge.ad_hoc_run(str(remote.device_jid), NS_MEDIA_PLAYER, self.profile,
+                               callback=self.ad_hoc_run_cb,
                                errback=self.main_wid.errback)
 
     def do_cmd(self, command):
         try:
             cmd_value = self.commands[command]
         except KeyError:
-            G.host.addNote(
+            G.host.add_note(
                 title=NOTE_TITLE,
                 message=_("{command} command is not managed").format(command=command),
                 level=C.XMLUI_DATA_LVL_WARNING)
@@ -130,44 +130,44 @@
             hidden = {xmlui.XMLUIPanel.escape(k):v
                       for k,v in self.ui_tpl.hidden.items()}
             data.update(hidden)
-            G.host.bridge.launchAction(
+            G.host.bridge.action_launch(
                 self.ui_tpl.submit_id, data, self.profile,
-                callback=self.updateUI,
+                callback=self.update_ui,
                 errback=self.main_wid.errback)
 
 
 class RemoteDeviceWidget(DeviceWidget):
 
-    def xmluiCb(self, data, cb_id, profile):
+    def xmlui_cb(self, data, cb_id, profile):
         if 'xmlui' in data:
             xml_ui = xmlui.create(
-                G.host, data['xmlui'], callback=self.xmluiCb, profile=profile)
+                G.host, data['xmlui'], callback=self.xmlui_cb, profile=profile)
             if isinstance(xml_ui, xmlui.XMLUIDialog):
-                self.main_wid.showRootWidget()
+                self.main_wid.show_root_widget()
                 xml_ui.show()
             else:
-                xml_ui.setCloseCb(self.onClose)
+                xml_ui.set_close_cb(self.on_close)
                 self.main_wid.layout.add_widget(xml_ui)
         else:
             if data:
                 log.warning(_("Unhandled data: {data}").format(data=data))
-            self.main_wid.showRootWidget()
+            self.main_wid.show_root_widget()
 
-    def onClose(self, __, reason):
+    def on_close(self, __, reason):
         if reason == C.XMLUI_DATA_CANCELLED:
-            self.main_wid.showRootWidget()
+            self.main_wid.show_root_widget()
         else:
             self.main_wid.layout.clear_widgets()
 
-    def adHocRunCb(self, data):
-        xml_ui = xmlui.create(G.host, data, callback=self.xmluiCb, profile=self.profile)
-        xml_ui.setCloseCb(self.onClose)
+    def ad_hoc_run_cb(self, data):
+        xml_ui = xmlui.create(G.host, data, callback=self.xmlui_cb, profile=self.profile)
+        xml_ui.set_close_cb(self.on_close)
         self.main_wid.layout.add_widget(xml_ui)
 
     def do_item_action(self, touch):
         self.main_wid.layout.clear_widgets()
-        G.host.bridge.adHocRun(str(self.entity_jid), '', self.profile,
-            callback=self.adHocRunCb, errback=self.main_wid.errback)
+        G.host.bridge.ad_hoc_run(str(self.entity_jid), '', self.profile,
+            callback=self.ad_hoc_run_cb, errback=self.main_wid.errback)
 
 
 class DevicesLayout(FloatLayout):
@@ -186,22 +186,22 @@
         FilterBehavior.__init__(self)
         TouchMenuBehavior.__init__(self)
         self.stack_layout = None
-        self.showRootWidget()
+        self.show_root_widget()
 
     def errback(self, failure_):
         """Generic errback which add a warning note and go back to root widget"""
-        G.host.addNote(
+        G.host.add_note(
             title=NOTE_TITLE,
             message=_("Can't use remote control: {reason}").format(reason=failure_),
             level=C.XMLUI_DATA_LVL_WARNING)
-        self.showRootWidget()
+        self.show_root_widget()
 
     def key_input(self, window, key, scancode, codepoint, modifier):
         if key == 27:
-            self.showRootWidget()
+            self.show_root_widget()
             return True
 
-    def showRootWidget(self):
+    def show_root_widget(self):
         self.layout.clear_widgets()
         devices_layout = DevicesLayout()
         self.stack_layout = devices_layout.layout
@@ -210,12 +210,12 @@
         self.get_remotes(found)
         self.discover_devices(found)
 
-    def adHocRemotesGetCb(self, remotes_data, found):
+    def ad_hoc_remotes_get_cb(self, remotes_data, found):
         found.insert(0, remotes_data)
         if len(found) == 2:
             self.show_devices(found)
 
-    def adHocRemotesGetEb(self, failure_, found):
+    def ad_hoc_remotes_get_eb(self, failure_, found):
         G.host.errback(failure_, title=_("discovery error"),
                        message=_("can't check remote controllers: {msg}"))
         found.insert(0, [])
@@ -223,17 +223,17 @@
             self.show_devices(found)
 
     def get_remotes(self, found):
-        self.host.bridge.adHocRemotesGet(
+        self.host.bridge.ad_hoc_remotes_get(
             self.profile,
-            callback=partial(self.adHocRemotesGetCb, found=found),
-            errback=partial(self.adHocRemotesGetEb,found=found))
+            callback=partial(self.ad_hoc_remotes_get_cb, found=found),
+            errback=partial(self.ad_hoc_remotes_get_eb,found=found))
 
-    def _discoFindByFeaturesCb(self, data, found):
+    def _disco_find_by_features_cb(self, data, found):
         found.append(data)
         if len(found) == 2:
             self.show_devices(found)
 
-    def _discoFindByFeaturesEb(self, failure_, found):
+    def _disco_find_by_features_eb(self, failure_, found):
         G.host.errback(failure_, title=_("discovery error"),
                        message=_("can't check devices: {msg}"))
         found.append(({}, {}, {}))
@@ -247,12 +247,12 @@
         except KeyError:
             msg = _("can't find ad-hoc commands namespace, is the plugin running?")
             log.warning(msg)
-            G.host.addNote(_("missing plugin"), msg, C.XMLUI_DATA_LVL_ERROR)
+            G.host.add_note(_("missing plugin"), msg, C.XMLUI_DATA_LVL_ERROR)
             return
-        self.host.bridge.discoFindByFeatures(
+        self.host.bridge.disco_find_by_features(
             [namespace], [], False, True, True, True, False, self.profile,
-            callback=partial(self._discoFindByFeaturesCb, found=found),
-            errback=partial(self._discoFindByFeaturesEb, found=found))
+            callback=partial(self._disco_find_by_features_cb, found=found),
+            errback=partial(self._disco_find_by_features_eb, found=found))
 
     def show_devices(self, found):
         remotes_data, (entities_services, entities_own, entities_roster) = found