From 1b82c21ec8897da285728f9e99e135fbd7406462 Mon Sep 17 00:00:00 2001 From: Ulrich Müller Date: Tue, 21 Mar 2023 18:05:59 +0100 Subject: Support the NO_COLOR environment variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: https://bugs.gentoo.org/902551 Signed-off-by: Ulrich Müller Closes: https://github.com/gentoo/gentoolkit/pull/26 Signed-off-by: Sam James --- pym/gentoolkit/base.py | 8 ++++++-- pym/gentoolkit/eclean/cli.py | 8 +++++--- pym/gentoolkit/ekeyword/ekeyword.py | 7 +++++-- pym/gentoolkit/equery/__init__.py | 4 ++-- 4 files changed, 18 insertions(+), 9 deletions(-) (limited to 'pym') diff --git a/pym/gentoolkit/base.py b/pym/gentoolkit/base.py index 8dfa2db..230e040 100644 --- a/pym/gentoolkit/base.py +++ b/pym/gentoolkit/base.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -# Copyright(c) 2009 - 2010, Gentoo Foundation +# Copyright(c) 2009-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 """Gentoolkit Base Module class to hold common module operation functions @@ -39,7 +39,11 @@ def initialize_configuration(): # Guess color output if ( gentoolkit.CONFIG["color"] == -1 - and (not sys.stdout.isatty() or os.getenv("NOCOLOR") in ("yes", "true")) + and ( + not sys.stdout.isatty() + or os.getenv("NO_COLOR") + or os.getenv("NOCOLOR") in ("yes", "true") + ) or gentoolkit.CONFIG["color"] == 0 ): pp.output.nocolor() diff --git a/pym/gentoolkit/eclean/cli.py b/pym/gentoolkit/eclean/cli.py index 23c7f3b..4902354 100644 --- a/pym/gentoolkit/eclean/cli.py +++ b/pym/gentoolkit/eclean/cli.py @@ -1,6 +1,6 @@ #!/usr/bin/python -# Copyright 2003-2016 Gentoo Foundation +# Copyright 2003-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 @@ -43,7 +43,7 @@ def printVersion(): print("%s (%s) - %s" % (__productname__, __version__, __description__)) print() print("Author: %s <%s>" % (__author__, __email__)) - print("Copyright 2003-2009 Gentoo Foundation") + print("Copyright 2003-2023 Gentoo Authors") print("Distributed under the terms of the GNU General Public License v2") @@ -615,7 +615,9 @@ def main(): # set default options options = {} options["nocolor"] = ( - port_settings.get("NOCOLOR") in ("yes", "true") or not sys.stdout.isatty() + port_settings.get("NO_COLOR") + or port_settings.get("NOCOLOR") in ("yes", "true") + or not sys.stdout.isatty() ) if options["nocolor"]: pp.output.nocolor() diff --git a/pym/gentoolkit/ekeyword/ekeyword.py b/pym/gentoolkit/ekeyword/ekeyword.py index d031c2f..70f44ea 100755 --- a/pym/gentoolkit/ekeyword/ekeyword.py +++ b/pym/gentoolkit/ekeyword/ekeyword.py @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 2014 Gentoo Foundation +# Copyright 2014-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # Written by Mike Frysinger @@ -533,7 +533,10 @@ def main(argv): parser.error("need ebuilds to process") if opts.style == "auto": - if not portage_settings().get("NOCOLOR", "false").lower() in ("no", "false"): + if not ( + portage_settings().get("NO_COLOR") + or portage_settings().get("NOCOLOR", "false").lower() in ("no", "false") + ): nocolor() opts.style = "short" else: diff --git a/pym/gentoolkit/equery/__init__.py b/pym/gentoolkit/equery/__init__.py index ae760c1..a83d31a 100644 --- a/pym/gentoolkit/equery/__init__.py +++ b/pym/gentoolkit/equery/__init__.py @@ -1,4 +1,4 @@ -# Copyright(c) 2009, Gentoo Foundation +# Copyright(c) 2009-2023 Gentoo Authors # # Licensed under the GNU General Public License, v2 @@ -218,7 +218,7 @@ def initialize_configuration(): # Guess color output if ( CONFIG["color"] == -1 - and os.getenv("NOCOLOR") in ("yes", "true") + and (os.getenv("NO_COLOR") or os.getenv("NOCOLOR") in ("yes", "true")) or CONFIG["color"] == 0 ): pp.output.nocolor() -- cgit v1.2.3