From 815009f647f4ae034f0b209a3b33c28ef9341de1 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Mon, 13 Feb 2023 14:15:15 +0100 Subject: [PATCH] core.ReviewState: Add __repr__() method --- osc/core.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/osc/core.py b/osc/core.py index bad98ad8..0991bd93 100644 --- a/osc/core.py +++ b/osc/core.py @@ -2749,6 +2749,23 @@ class ReviewState(AbstractState): review_node.find('comment').text: self.comment = review_node.find('comment').text.strip() + def __repr__(self): + result = super().__repr__() + result += "(" + result += f"{self.state}" + + if self.who: + result += f" by {self.who}" + + for by in ("user", "group", "project", "package"): + by_value = getattr(self, f"by_{by}", None) + if by_value: + result += f" [{by} {by_value}])" + break + + result += ")" + return result + def get_node_attrs(self): return ('state', 'by_user', 'by_group', 'by_project', 'by_package', 'who', 'when')