From 70aa9903b93789d468b17857c88d5b29e64824d9 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 26 Jan 2021 11:41:02 -0800 Subject: [PATCH] list_realms: Convert percent formatting to "".format. Signed-off-by: Anders Kaseorg --- zerver/management/commands/list_realms.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/zerver/management/commands/list_realms.py b/zerver/management/commands/list_realms.py index 80f556a317..b815aabd80 100644 --- a/zerver/management/commands/list_realms.py +++ b/zerver/management/commands/list_realms.py @@ -22,25 +22,25 @@ Usage examples: def handle(self, *args: Any, **options: Any) -> None: realms = Realm.objects.all() - outer_format = "%-5s %-20s %-30s %-50s" - inner_format = "%-40s %s" + outer_format = "{:<5} {:<20} {!s:<30} {:<50}" + inner_format = "{:<40} {}" deactivated = False if not options["all"]: - print(outer_format % ("id", "string_id", "name", "domain")) - print(outer_format % ("--", "---------", "----", "------")) + print(outer_format.format("id", "string_id", "name", "domain")) + print(outer_format.format("--", "---------", "----", "------")) for realm in realms: display_string_id = realm.string_id if realm.string_id != '' else "''" if realm.deactivated: - print(self.style.ERROR(outer_format % ( + print(self.style.ERROR(outer_format.format( realm.id, display_string_id, realm.name, realm.uri))) deactivated = True else: - print(outer_format % (realm.id, display_string_id, realm.name, realm.uri)) + print(outer_format.format(realm.id, display_string_id, realm.name, realm.uri)) if deactivated: print(self.style.WARNING("\nRed rows represent deactivated realms.")) sys.exit(0) @@ -58,17 +58,17 @@ Usage examples: for key in identifier_attributes: if realm.deactivated: - print(self.style.ERROR(inner_format % (key, realm_dict[key]))) + print(self.style.ERROR(inner_format.format(key, realm_dict[key]))) deactivated = True else: - print(inner_format % (key, realm_dict[key])) + print(inner_format.format(key, realm_dict[key])) for key, value in sorted(realm_dict.items()): if key not in identifier_attributes: if realm.deactivated: - print(self.style.ERROR(inner_format % (key, value))) + print(self.style.ERROR(inner_format.format(key, value))) else: - print(inner_format % (key, value)) + print(inner_format.format(key, value)) print("-" * 80) if deactivated: