From: Aarni Koskela Date: Wed, 25 Jan 2023 20:08:33 +0000 (+0200) Subject: Modernize some string formatting X-Git-Tag: v2.12.0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6bf793ae5b902b3e3f2cb494f2fc230c2641890c;p=thirdparty%2Fbabel.git Modernize some string formatting --- diff --git a/babel/messages/extract.py b/babel/messages/extract.py index 39e26a9c..5a34f645 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 b10bb682..5baefbbb 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): """