mirror of https://github.com/zulip/zulip.git
list_realms: Convert percent formatting to "".format.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
c36a66cc1b
commit
70aa9903b9
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue