From e132d093e7c63d040ce36cb290972bc72dbc15a6 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Mon, 13 Feb 2023 13:59:32 +0100 Subject: [PATCH] core.Action: Add __repr__() method --- osc/core.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/osc/core.py b/osc/core.py index ab1bc305..bad98ad8 100644 --- a/osc/core.py +++ b/osc/core.py @@ -2892,6 +2892,26 @@ class Action: for i in Action.type_args[type]: setattr(self, i, kwargs.get(i)) + def __repr__(self): + result = super().__repr__() + result += "(" + result += f"type={self.type}" + + src_pkg = self.src_pkg_object + if src_pkg: + result += f" source={src_pkg.project}/{src_pkg.name}" + elif getattr(self, "src_project", None): + result += f" source={self.src_project}" + + tgt_pkg = self.tgt_pkg_object + if tgt_pkg: + result += f" target={tgt_pkg.project}/{tgt_pkg.name}" + elif getattr(self, "tgt_project", None): + result += f" target={self.tgt_project}" + + result += ")" + return result + @property def src_pkg_object(self): if not getattr(self, "src_project", None) or not getattr(self, "src_package", None):