Mercurial > libervia-backend
diff sat_frontends/jp/cmd_debug.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 | 691dbd78981c |
children | 4b842c1fb686 |
line wrap: on
line diff
--- a/sat_frontends/jp/cmd_debug.py Fri Apr 07 15:18:39 2023 +0200 +++ b/sat_frontends/jp/cmd_debug.py Sat Apr 08 13:54:42 2023 +0200 @@ -28,7 +28,7 @@ class BridgeCommon(object): - def evalArgs(self): + def eval_args(self): if self.args.arg: try: return eval("[{}]".format(",".join(self.args.arg))) @@ -67,7 +67,7 @@ elif "profile" in argspec.args: kwargs["profile"] = self.profile - args = self.evalArgs() + args = self.eval_args() try: ret = await method( @@ -100,12 +100,12 @@ self.parser.add_argument("arg", nargs="*", help=_("argument of the signal")) async def start(self): - args = self.evalArgs() + args = self.eval_args() json_args = json.dumps(args) # XXX: we use self.args.profile and not self.profile # because we want the raw profile_key (so plugin handle C.PROF_KEY_NONE) try: - await self.host.bridge.debugFakeSignal( + await self.host.bridge.debug_signal_fake( self.args.signal, json_args, self.args.profile ) except Exception as e: @@ -115,11 +115,11 @@ self.host.quit() -class Bridge(base.CommandBase): +class bridge(base.CommandBase): subcommands = (Method, Signal) def __init__(self, host): - super(Bridge, self).__init__( + super(bridge, self).__init__( host, "bridge", use_profile=False, help=_("bridge s(t)imulation") ) @@ -144,7 +144,7 @@ help=_("stream direction filter"), ) - async def printXML(self, direction, xml_data, profile): + async def print_xml(self, direction, xml_data, profile): if self.args.direction == "in" and direction != "IN": return if self.args.direction == "out" and direction != "OUT": @@ -186,7 +186,7 @@ self.disp("") async def start(self): - self.host.bridge.register_signal("xmlLog", self.printXML, "plugin") + self.host.bridge.register_signal("xml_log", self.print_xml, "plugin") class Theme(base.CommandBase): @@ -220,7 +220,7 @@ class Debug(base.CommandBase): - subcommands = (Bridge, Monitor, Theme) + subcommands = (bridge, Monitor, Theme) def __init__(self, host): super(Debug, self).__init__(