Skip to content

Commit fa2de10

Browse files
committed
Modernize some string formatting
1 parent 5054afd commit fa2de10

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

babel/messages/extract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def check_and_call_extract_file(
276276
options=options,
277277
strip_comment_tags=strip_comment_tags
278278
):
279-
yield (filename, ) + message_tuple
279+
yield (filename, *message_tuple)
280280

281281
break
282282

babel/messages/frontend.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -942,12 +942,10 @@ def run(self, argv=None):
942942
self._configure_logging(options.loglevel)
943943
if options.list_locales:
944944
identifiers = localedata.locale_identifiers()
945-
longest = max(len(identifier) for identifier in identifiers)
946-
identifiers.sort()
947-
format = '%%-%ds %%s' % (longest + 1)
948-
for identifier in identifiers:
945+
id_width = max(len(identifier) for identifier in identifiers) + 1
946+
for identifier in sorted(identifiers):
949947
locale = Locale.parse(identifier)
950-
print(format % (identifier, locale.english_name))
948+
print(f"{identifier:<{id_width}} {locale.english_name}")
951949
return 0
952950

953951
if not args:
@@ -979,11 +977,9 @@ def _configure_logging(self, loglevel):
979977
def _help(self):
980978
print(self.parser.format_help())
981979
print("commands:")
982-
longest = max(len(command) for command in self.commands)
983-
format = " %%-%ds %%s" % max(8, longest + 1)
984-
commands = sorted(self.commands.items())
985-
for name, description in commands:
986-
print(format % (name, description))
980+
cmd_width = max(8, max(len(command) for command in self.commands) + 1)
981+
for name, description in sorted(self.commands.items()):
982+
print(f" {name:<{cmd_width}} {description}")
987983

988984
def _configure_command(self, cmdname, argv):
989985
"""

0 commit comments

Comments
 (0)