Mercurial > libervia-backend
diff sat_frontends/jp/cmd_debug.py @ 3568:04283582966f
core, frontends: fix invalid translatable strings.
Some f-strings where used in translatable text, this has been fixed by using explicit
`format()` call (using a script based on `tokenize`).
As tokenize messes with spaces, a reformating tool (`black`) has been applied to some
files afterwards.
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 14 Jun 2021 18:35:12 +0200 |
parents | be6d91572633 |
children | 691dbd78981c |
line wrap: on
line diff
--- a/sat_frontends/jp/cmd_debug.py Mon Jun 14 12:19:21 2021 +0200 +++ b/sat_frontends/jp/cmd_debug.py Mon Jun 14 18:35:12 2021 +0200 @@ -53,20 +53,19 @@ self.parser.add_argument( "method", type=str, help=_("name of the method to execute") ) - self.parser.add_argument( - "arg", nargs="*", help=_("argument of the method") - ) + self.parser.add_argument("arg", nargs="*", help=_("argument of the method")) async def start(self): method = getattr(self.host.bridge, self.args.method) import inspect + argspec = inspect.getargspec(method) kwargs = {} - if 'profile_key' in argspec.args: - kwargs['profile_key'] = self.profile - elif 'profile' in argspec.args: - kwargs['profile'] = self.profile + if "profile_key" in argspec.args: + kwargs["profile_key"] = self.profile + elif "profile" in argspec.args: + kwargs["profile"] = self.profile args = self.evalArgs() @@ -76,7 +75,12 @@ **kwargs, ) except Exception as e: - self.disp(_(f"Error while executing {self.args.method}: {e}"), error=True) + self.disp( + _("Error while executing {method}: {e}").format( + method=self.args.method, e=e + ), + error=True, + ) self.host.quit(C.EXIT_ERROR) else: if ret is not None: @@ -92,12 +96,8 @@ BridgeCommon.__init__(self) def add_parser_options(self): - self.parser.add_argument( - "signal", type=str, help=_("name of the signal to send") - ) - self.parser.add_argument( - "arg", nargs="*", help=_("argument of the signal") - ) + self.parser.add_argument("signal", type=str, help=_("name of the signal to send")) + self.parser.add_argument("arg", nargs="*", help=_("argument of the signal")) async def start(self): args = self.evalArgs() @@ -105,9 +105,11 @@ # 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(self.args.signal, json_args, self.args.profile) + await self.host.bridge.debugFakeSignal( + self.args.signal, json_args, self.args.profile + ) except Exception as e: - self.disp(_(f"Can't send fake signal: {e}"), error=True) + self.disp(_("Can't send fake signal: {e}").format(e=e), error=True) self.host.quit(C.EXIT_ERROR) else: self.host.quit() @@ -198,18 +200,17 @@ async def start(self): for attr in dir(C): - if not attr.startswith('A_'): + if not attr.startswith("A_"): continue color = getattr(C, attr) - if attr == 'A_LEVEL_COLORS': + if attr == "A_LEVEL_COLORS": # This constant contains multiple colors - self.disp('LEVEL COLORS: ', end=' ') + self.disp("LEVEL COLORS: ", end=" ") for idx, c in enumerate(color): - last = idx == len(color)-1 - end = '\n' if last else ' ' + last = idx == len(color) - 1 + end = "\n" if last else " " self.disp( - c + f'LEVEL_{idx}' + A.RESET + (', ' if not last else ''), - end=end + c + f"LEVEL_{idx}" + A.RESET + (", " if not last else ""), end=end ) else: text = attr[2:]