From: Ondrej Lichtner <olichtne(a)redhat.com>
The parameter can be used to enable/disable colourization. Currently,
only the PASS/FAIL strings indicating a job success state are supported
for colourization, however this might change later.
Default value is False, this changes the current behaviour where PASS
and FAIL was automatically coloured, but this probably wasn't a good
idea since a normal expectation for a formatter would be to do just the
simplest operation unless specifically configured to something more.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/RunSummaryFormatter.py | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lnst/Controller/RunSummaryFormatter.py
b/lnst/Controller/RunSummaryFormatter.py
index 670c1f7..b569b50 100644
--- a/lnst/Controller/RunSummaryFormatter.py
+++ b/lnst/Controller/RunSummaryFormatter.py
@@ -24,16 +24,21 @@ class RunFormatterException(ControllerError):
pass
class RunSummaryFormatter(object):
- def __init__(self, level=ResultLevel.IMPORTANT):
+ def __init__(self, level=ResultLevel.IMPORTANT, colourize=False):
#TODO changeable format?
self._format = ""
self._level = level
+ self._colourize = colourize
def _format_success(self, success):
if success:
- return decorate_with_preset("PASS", "pass")
+ return (decorate_with_preset("PASS", "pass")
+ if self._colourize
+ else "PASS")
else:
- return decorate_with_preset("FAIL", "fail")
+ return (decorate_with_preset("FAIL", "fail")
+ if self._colourize
+ else "FAIL")
def _format_source(self, res):
if isinstance(res, JobResult):
--
2.21.0