]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Modernize some string formatting
authorAarni Koskela <akx@iki.fi>
Wed, 25 Jan 2023 20:08:33 +0000 (22:08 +0200)
committerAarni Koskela <akx@iki.fi>
Wed, 25 Jan 2023 20:34:47 +0000 (22:34 +0200)
babel/messages/extract.py
babel/messages/frontend.py

index 39e26a9c7f3a0acc35e80d415439442cd9d3afa6..5a34f645dd56b7f509744162681d0a8df82218ea 100644 (file)
@@ -276,7 +276,7 @@ def check_and_call_extract_file(
             options=options,
             strip_comment_tags=strip_comment_tags
         ):
-            yield (filename, ) + message_tuple
+            yield (filename, *message_tuple)
 
         break
 
index b10bb6821ec296d222325b25bae115a06d79ebfa..5baefbbb3988d087257d4cfcf3089ba130a34711 100644 (file)
@@ -942,12 +942,10 @@ class CommandLineInterface:
         self._configure_logging(options.loglevel)
         if options.list_locales:
             identifiers = localedata.locale_identifiers()
-            longest = max(len(identifier) for identifier in identifiers)
-            identifiers.sort()
-            format = '%%-%ds %%s' % (longest + 1)
-            for identifier in identifiers:
+            id_width = max(len(identifier) for identifier in identifiers) + 1
+            for identifier in sorted(identifiers):
                 locale = Locale.parse(identifier)
-                print(format % (identifier, locale.english_name))
+                print(f"{identifier:<{id_width}} {locale.english_name}")
             return 0
 
         if not args:
@@ -979,11 +977,9 @@ class CommandLineInterface:
     def _help(self):
         print(self.parser.format_help())
         print("commands:")
-        longest = max(len(command) for command in self.commands)
-        format = "  %%-%ds %%s" % max(8, longest + 1)
-        commands = sorted(self.commands.items())
-        for name, description in commands:
-            print(format % (name, description))
+        cmd_width = max(8, max(len(command) for command in self.commands) + 1)
+        for name, description in sorted(self.commands.items()):
+            print(f"  {name:<{cmd_width}} {description}")
 
     def _configure_command(self, cmdname, argv):
         """