Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

list_realms: Convert percent formatting to "".format.

Anders Kaseorg70aa9903b937
diff --git a/zerver/management/commands/list_realms.py b/zerver/management/commands/list_realms.py
index 80f556a3178..b815aabd800 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: