From 5340e18c22dd7063a5b5bb1fd4de319752213b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian-Samuel=20Geb=C3=BChr?= Date: Wed, 26 Jul 2023 11:32:59 +0200 Subject: [PATCH] Add showdiff --- mastodon_blocklist_deploy/models.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mastodon_blocklist_deploy/models.py b/mastodon_blocklist_deploy/models.py index b33e00d..1b87c9e 100644 --- a/mastodon_blocklist_deploy/models.py +++ b/mastodon_blocklist_deploy/models.py @@ -138,3 +138,18 @@ class Instance: table.add_row(diff["local"].domain, diff["local"].status_str(), diff["remote"].status_str()) console = Console() console.print(table) + + @staticmethod + def show_diff(instanceA, instanceB, column_names=('Input', 'Original')): + from rich.table import Table + from rich.console import Console + table = Table(title="Differences", expand=True, show_lines=True) + + table.add_column("Attribute", style="cyan") + table.add_column(column_names[0], style="green") + table.add_column(column_names[1], style="magenta") + compare_attributes = ["domain", "severity", "obfuscate", "private_comment", "public_comment", "reject_media", "reject_reports"] + for attr in compare_attributes: + table.add_row(attr, str(getattr(instanceA, attr)), str(getattr(instanceB, attr))) + console = Console() + console.print(table)