Add showdiff

This commit is contained in:
moanos [he/him] 2023-07-26 11:32:59 +02:00
parent 626516e98c
commit 5340e18c22

View File

@ -138,3 +138,18 @@ class Instance:
table.add_row(diff["local"].domain, diff["local"].status_str(), diff["remote"].status_str()) table.add_row(diff["local"].domain, diff["local"].status_str(), diff["remote"].status_str())
console = Console() console = Console()
console.print(table) 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)