Improve report formatting: compact sections and row format for rules
- Remove extra lines between section headers and content - Add blank lines only after sections for better readability - Add _print_rule_differences() method to display rules in row format - Rules show device names as rows with detailed rule info below each - More space-efficient report layout
This commit is contained in:
parent
cacdfe7a77
commit
3ea2798857
@ -177,62 +177,56 @@ class DeviceComparison:
|
||||
# Print firmware info
|
||||
print("\n" + "-" * 80)
|
||||
print("FIRMWARE DIFFERENCES")
|
||||
print("-" * 80)
|
||||
|
||||
if comparison['firmware']:
|
||||
self._print_differences(comparison['firmware'], device1['name'], device2['name'])
|
||||
else:
|
||||
print("No differences found")
|
||||
print() # Blank line after section
|
||||
|
||||
# Print network differences
|
||||
print("\n" + "-" * 80)
|
||||
print("NETWORK DIFFERENCES")
|
||||
print("-" * 80)
|
||||
|
||||
print("NETWORK DIFFERENCES")
|
||||
if comparison['network']:
|
||||
self._print_differences(comparison['network'], device1['name'], device2['name'])
|
||||
else:
|
||||
print("No differences found")
|
||||
print() # Blank line after section
|
||||
|
||||
# Print MQTT differences
|
||||
print("\n" + "-" * 80)
|
||||
print("MQTT DIFFERENCES")
|
||||
print("-" * 80)
|
||||
|
||||
print("MQTT DIFFERENCES")
|
||||
if comparison['mqtt']:
|
||||
self._print_differences(comparison['mqtt'], device1['name'], device2['name'])
|
||||
else:
|
||||
print("No differences found")
|
||||
print() # Blank line after section
|
||||
|
||||
# Print SetOption differences
|
||||
print("\n" + "-" * 80)
|
||||
print("SETOPTION DIFFERENCES")
|
||||
print("-" * 80)
|
||||
|
||||
print("SETOPTION DIFFERENCES")
|
||||
if comparison['setoptions']:
|
||||
self._print_differences(comparison['setoptions'], device1['name'], device2['name'])
|
||||
else:
|
||||
print("No differences found")
|
||||
print() # Blank line after section
|
||||
|
||||
# Print Rule differences
|
||||
print("\n" + "-" * 80)
|
||||
print("RULE DIFFERENCES")
|
||||
# Print Rule differences (special row format)
|
||||
print("-" * 80)
|
||||
|
||||
print("RULE DIFFERENCES")
|
||||
if comparison['rules']:
|
||||
self._print_differences(comparison['rules'], device1['name'], device2['name'])
|
||||
self._print_rule_differences(comparison['rules'], device1['name'], device2['name'])
|
||||
else:
|
||||
print("No differences found")
|
||||
print() # Blank line after section
|
||||
|
||||
# Print other differences
|
||||
print("\n" + "-" * 80)
|
||||
print("OTHER CONFIGURATION DIFFERENCES")
|
||||
print("-" * 80)
|
||||
|
||||
print("OTHER CONFIGURATION DIFFERENCES")
|
||||
if comparison['other']:
|
||||
self._print_differences(comparison['other'], device1['name'], device2['name'])
|
||||
else:
|
||||
print("No differences found")
|
||||
print() # Blank line after section
|
||||
|
||||
print("\n" + "=" * 80)
|
||||
print("END OF REPORT")
|
||||
@ -281,3 +275,38 @@ class DeviceComparison:
|
||||
val2 = val2[:57] + "..."
|
||||
|
||||
print(f"{key:<{key_width}} {val1:<{val1_width}} {val2:<{val2_width}}")
|
||||
|
||||
def _print_rule_differences(self, differences: List[Dict], device1_name: str, device2_name: str) -> None:
|
||||
"""
|
||||
Print rule differences in row format (device per row).
|
||||
|
||||
Args:
|
||||
differences: List of difference dictionaries
|
||||
device1_name: First device name
|
||||
device2_name: Second device name
|
||||
"""
|
||||
if not differences:
|
||||
return
|
||||
|
||||
for diff in differences:
|
||||
rule_key = str(diff['key'])
|
||||
val1 = diff['device1_value']
|
||||
val2 = diff['device2_value']
|
||||
|
||||
print(f"\n{rule_key}:")
|
||||
|
||||
# Print Device 1
|
||||
print(f" {device1_name}:")
|
||||
if isinstance(val1, dict):
|
||||
for key, value in val1.items():
|
||||
print(f" {key}: {value}")
|
||||
else:
|
||||
print(f" {val1}")
|
||||
|
||||
# Print Device 2
|
||||
print(f" {device2_name}:")
|
||||
if isinstance(val2, dict):
|
||||
for key, value in val2.items():
|
||||
print(f" {key}: {value}")
|
||||
else:
|
||||
print(f" {val2}")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user