list_realms: Convert percent formatting to "".format.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-01-26 11:41:02 -08:00 committed by Tim Abbott
parent c36a66cc1b
commit 70aa9903b9
1 changed files with 10 additions and 10 deletions

View File

@ -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: