From 89e48734bf13446024e9009bce7e77cbd4255840 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Fri, 5 Jun 2020 12:22:49 +0200 Subject: [PATCH] Let config file and command line override NO_COLOR envvar --- cdist/configuration.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cdist/configuration.py b/cdist/configuration.py index f68a5e09..a12940b0 100644 --- a/cdist/configuration.py +++ b/cdist/configuration.py @@ -256,14 +256,12 @@ class ColoredOutputOption(BooleanOption): @staticmethod def translate(val): - if 'NO_COLOR' in os.environ: - return False - elif isinstance(val, bool): + if isinstance(val, bool): return val - elif val == 'auto': - return sys.stdout.isatty() - else: + elif val in configparser.ConfigParser.BOOLEAN_STATES: return configparser.ConfigParser.BOOLEAN_STATES[val] + elif val == 'auto': + return 'NO_COLOR' not in os.environ and sys.stdout.isatty() ColoredOutputOption.DEFAULT = ColoredOutputOption.translate(