Skip to content

Commit

Permalink
Modernize some string formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Jan 25, 2023
1 parent 5054afd commit fa2de10
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion babel/messages/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 6 additions & 10 deletions babel/messages/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,12 +942,10 @@ def run(self, argv=None):
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:
Expand Down Expand Up @@ -979,11 +977,9 @@ def _configure_logging(self, loglevel):
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):
"""
Expand Down

0 comments on commit fa2de10

Please sign in to comment.