From a310d6bdad7372b9d8b5d85519ea8a46fe911643 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 23 Nov 2017 11:56:23 -0500 Subject: [PATCH] Implement __repr__ for _EnumerationField MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Philippe Proulx Reviewed-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau --- bindings/python/bt2/bt2/fields.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bindings/python/bt2/bt2/fields.py b/bindings/python/bt2/bt2/fields.py index 507f047f..2f910635 100644 --- a/bindings/python/bt2/bt2/fields.py +++ b/bindings/python/bt2/bt2/fields.py @@ -366,6 +366,10 @@ class _EnumerationField(_IntegerField): def _set_value(self, value): self.integer_field.value = value + def __repr__(self): + labels = [repr(v.name) for v in self.mappings] + return '{} ({})'.format(self._value, ', '.join(labels)) + value = property(fset=_set_value) @property -- 2.34.1