diff sat_frontends/jp/cmd_list.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 059742e925f2
children 524856bd7b19
line wrap: on
line diff
--- a/sat_frontends/jp/cmd_list.py	Mon Jun 14 12:19:21 2021 +0200
+++ b/sat_frontends/jp/cmd_list.py	Mon Jun 14 18:35:12 2021 +0200
@@ -61,7 +61,7 @@
                     self.getPubsubExtra(),
                     self.profile,
                 ),
-                type_check=list
+                type_check=list,
             )
         except Exception as e:
             self.disp(f"can't get lists: {e}", error=True)
@@ -72,7 +72,6 @@
 
 
 class Set(base.CommandBase):
-
     def __init__(self, host):
         base.CommandBase.__init__(
             self,
@@ -128,10 +127,10 @@
                 self.args.service,
                 self.args.node,
                 values,
-                '',
+                "",
                 self.args.item,
                 data_format.serialise(extra),
-                self.profile
+                self.profile,
             )
         except Exception as e:
             self.disp(f"can't set list item: {e}", error=True)
@@ -142,7 +141,6 @@
 
 
 class Delete(base.CommandBase):
-
     def __init__(self, host):
         base.CommandBase.__init__(
             self,
@@ -183,10 +181,10 @@
                 self.profile,
             )
         except Exception as e:
-            self.disp(_(f"can't delete item: {e}"), error=True)
+            self.disp(_("can't delete item: {e}").format(e=e), error=True)
             self.host.quit(C.EXIT_BRIDGE_ERRBACK)
         else:
-            self.disp(_(f"item {self.args.item} has been deleted"))
+            self.disp(_("item {item} has been deleted").format(item=self.args.item))
             self.host.quit(C.EXIT_OK)
 
 
@@ -262,7 +260,10 @@
         self.disp(_("Tickets uploaded successfully"), 2)
 
     async def onProgressError(self, error_msg):
-        self.disp(_(f"Error while uploading tickets: {error_msg}"), error=True)
+        self.disp(
+            _("Error while uploading tickets: {error_msg}").format(error_msg=error_msg),
+            error=True,
+        )
 
     async def start(self):
         if self.args.location is None:
@@ -270,7 +271,10 @@
             for name in ("option", "service", "node"):
                 if getattr(self.args, name):
                     self.parser.error(
-                        _(f"{name} argument can't be used without location argument"))
+                        _(
+                            "{name} argument can't be used without location argument"
+                        ).format(name=name)
+                    )
             if self.args.importer is None:
                 self.disp(
                     "\n".join(
@@ -297,8 +301,14 @@
             if self.args.progress:
                 # we use a custom progress bar template as we want a counter
                 self.pbar_template = [
-                    _("Progress: "), ["Percentage"], " ", ["Bar"], " ",
-                    ["Counter"], " ", ["ETA"]
+                    _("Progress: "),
+                    ["Percentage"],
+                    " ",
+                    ["Bar"],
+                    " ",
+                    ["Counter"],
+                    " ",
+                    ["ETA"],
                 ]
 
             options = {key: value for key, value in self.args.option}
@@ -306,8 +316,10 @@
             if fields_map:
                 if FIELDS_MAP in options:
                     self.parser.error(
-                        _("fields_map must be specified either preencoded in --option or "
-                          "using --map, but not both at the same time")
+                        _(
+                            "fields_map must be specified either preencoded in --option or "
+                            "using --map, but not both at the same time"
+                        )
                     )
                 options[FIELDS_MAP] = json.dumps(fields_map)
 
@@ -322,7 +334,7 @@
                 )
             except Exception as e:
                 self.disp(
-                    _(f"Error while trying to import tickets: {e}"),
+                    _("Error while trying to import tickets: {e}").format(e=e),
                     error=True,
                 )
                 self.host.quit(C.EXIT_BRIDGE_ERRBACK)