diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5f36e85..b16f2c1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,6 +27,7 @@ jobs: # MANDATORY CHECKS USING CURRENT DEVELOPMENT INTERPRETER - dependencies: > pylint + python3-deepdiff python3-dbus python3-dbus-python-client-gen python3-justbytes diff --git a/.github/workflows/weekly.yml b/.github/workflows/weekly.yml index f9f9b3a..8c51c37 100644 --- a/.github/workflows/weekly.yml +++ b/.github/workflows/weekly.yml @@ -17,6 +17,7 @@ jobs: # PYTHON CHECKS ON NEXT FEDORA PYTHON AND PYTHON TOOLS VERSION - dependencies: > pylint + python3-deepdiff python3-dbus python3-dbus-python-client-gen python3-gobject diff --git a/scripts/monitor_dbus_signals.py b/scripts/monitor_dbus_signals.py index 289fad8..56dd9a8 100755 --- a/scripts/monitor_dbus_signals.py +++ b/scripts/monitor_dbus_signals.py @@ -51,6 +51,7 @@ # isort: THIRDPARTY import dbus import dbus.mainloop.glib + from deepdiff.diff import DeepDiff from gi.repository import GLib # isort: FIRSTPARTY @@ -451,6 +452,13 @@ def __repr__(self): f"{self.key!r}, {self.new_value!r})" ) + def __str__(self): + return ( + f"Added Property:{os.linesep} {self.object_path}{os.linesep}" + f" {self.interface_name}{os.linesep} {self.key}{os.linesep}" + f" {self.new_value}" + ) + class RemovedProperty(Diff): # pylint: disable=too-few-public-methods """ Property appears in recorded result but not in new result. @@ -468,6 +476,13 @@ def __repr__(self): f"{self.key!r}, {self.old_value!r})" ) + def __str__(self): + return ( + f"Removed Property:{os.linesep} {self.object_path}{os.linesep}" + f" {self.interface_name}{os.linesep} {self.key}{os.linesep}" + f" {self.old_value}" + ) + class DifferentProperty(Diff): # pylint: disable=too-few-public-methods """ Difference between two properties. @@ -488,6 +503,19 @@ def __repr__(self): f"{self.key!r}, {self.old_value!r}, {self.new_value!r})" ) + def __str__(self): + return ( + f"Different Property:{os.linesep}" + f" {self.object_path}{os.linesep} {self.key}{os.linesep}" + f" {self.old_value}{os.linesep}" + f" {self.new_value}{os.linesep}" + ) + os.linesep.join( + f" {line}" + for line in DeepDiff(self.old_value, self.new_value) + .pretty() + .split(os.linesep) + ) + class NotInvalidatedProperty(Diff): # pylint: disable=too-few-public-methods """ Represents a case where the property should have been invalidated but @@ -510,6 +538,14 @@ def __repr__(self): f"{self.new_value!r})" ) + def __str__(self): + return ( + f"Not Invalidated Property:{os.linesep}" + f" {self.object_path}{os.linesep}" + f" {self.interface_name}{os.linesep} {self.key}{os.linesep}" + f" {self.new_value}" + ) + class ChangedProperty(Diff): # pylint: disable=too-few-public-methods """ Represents a case where the property should have been constant but @@ -532,6 +568,18 @@ def __repr__(self): f"{self.new_value!r})" ) + def __str__(self): + return ( + f"Changed Property:{os.linesep} {self.object_path}{os.linesep}" + f" {self.interface_name}{os.linesep} {self.key}{os.linesep}" + f" {self.old_value}{os.linesep} {self.new_value}{os.linesep}" + ) + os.linesep.join( + f" {line}" + for line in DeepDiff(self.old_value, self.new_value) + .pretty() + .split(os.linesep) + ) + class RemovedObjectPath(Diff): # pylint: disable=too-few-public-methods """ Object path appears in recorded result but not in new result. @@ -544,6 +592,12 @@ def __init__(self, object_path, old_value): def __repr__(self): return f"RemovedObjectPath({self.object_path!r}, {self.old_value!r})" + def __str__(self): + return ( + f"Removed Object Path:{os.linesep}" + f"{self.object_path}{os.linesep} {self.old_value}" + ) + class AddedInterface(Diff): # pylint: disable=too-few-public-methods """ Interface appears in new result but not in recorded result. @@ -560,6 +614,12 @@ def __repr__(self): f"{self.new_value!r})" ) + def __str__(self): + return ( + f"Added Interface:{os.linesep} {self.object_path}{os.linesep}" + f" {self.interface_name}{os.linesep} {self.new_value}" + ) + class AddedObjectPath(Diff): # pylint: disable=too-few-public-methods """ Object path appears in new result but not in recorded result. @@ -572,6 +632,12 @@ def __init__(self, object_path, new_value): def __repr__(self): return f"AddedObjectPath({self.object_path!r}, {self.new_value!r})" + def __str__(self): + return ( + f"Added Object Path:{os.linesep}" + f" {self.object_path}{os.linesep} {self.new_value}" + ) + class RemovedInterface(Diff): # pylint: disable=too-few-public-methods """ Interface appears in recorded result but not in new result. @@ -588,6 +654,13 @@ def __repr__(self): f"{self.old_value!r})" ) + def __str__(self): + return ( + f"Removed Interface:{os.linesep}" + f" {self.object_path}{os.linesep}" + f" {self.interface_name}{os.linesep} {self.old_value}" + ) + class MissingInterface(Diff): # pylint: disable=too-few-public-methods """ Attempted to update a property on this interface, but the interface @@ -601,6 +674,12 @@ def __init__(self, object_path, interface_name): def __repr__(self): return f"MissingInterface({self.object_path!r}, {self.interface_name!r}" + def __str__(self): + return ( + f"Missing Interface:{os.linesep}" + f" {self.object_path}{os.linesep} {self.interface_name}" + ) + def _check_props(object_path, ifn, old_props, new_props): """ Find differences between two sets of properties. @@ -741,5 +820,5 @@ def _check(): if not result: sys.exit(0) - print(os.linesep.join(sorted(repr(diff) for diff in result))) + print(os.linesep.join(sorted(str(diff) for diff in result))) sys.exit(1)