diff options
author | Aarni Koskela <akx@iki.fi> | 2023-01-25 22:08:33 +0200 |
---|---|---|
committer | Aarni Koskela <akx@iki.fi> | 2023-01-25 22:34:47 +0200 |
commit | 6bf793ae5b902b3e3f2cb494f2fc230c2641890c (patch) | |
tree | f9f9c4a1fce47bbfa1769a07bd95cebe4178d02b | |
parent | 28ea5feebed2f83262d6240354900b07d2633bce (diff) | |
download | babel-6bf793ae5b902b3e3f2cb494f2fc230c2641890c.tar.gz |
Modernize some string formatting
-rw-r--r-- | babel/messages/extract.py | 2 | ||||
-rw-r--r-- | babel/messages/frontend.py | 16 |
2 files changed, 7 insertions, 11 deletions
diff --git a/babel/messages/extract.py b/babel/messages/extract.py index 39e26a9..5a34f64 100644 --- a/babel/messages/extract.py +++ b/babel/messages/extract.py @@ -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 diff --git a/babel/messages/frontend.py b/babel/messages/frontend.py index b10bb68..5baefbb 100644 --- a/babel/messages/frontend.py +++ b/babel/messages/frontend.py @@ -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): """ |