diff options
| author | Ulrich Müller <ulm@gentoo.org> | 2023-03-21 18:05:59 +0100 |
|---|---|---|
| committer | Sam James <sam@gentoo.org> | 2023-03-22 03:36:35 +0000 |
| commit | 1b82c21ec8897da285728f9e99e135fbd7406462 (patch) | |
| tree | 334e467e44a1dcfda17639c2d72c1b4734ff9309 /pym | |
| parent | 3bb68da27b4c47e86dbfd5f0ae6386a2a53f89f9 (diff) | |
| download | gentoolkit-1b82c21ec8897da285728f9e99e135fbd7406462.tar.gz | |
Support the NO_COLOR environment variable
Bug: https://bugs.gentoo.org/902551
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
Closes: https://github.com/gentoo/gentoolkit/pull/26
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'pym')
| -rw-r--r-- | pym/gentoolkit/base.py | 8 | ||||
| -rw-r--r-- | pym/gentoolkit/eclean/cli.py | 8 | ||||
| -rwxr-xr-x | pym/gentoolkit/ekeyword/ekeyword.py | 7 | ||||
| -rw-r--r-- | pym/gentoolkit/equery/__init__.py | 4 |
4 files changed, 18 insertions, 9 deletions
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 <vapier@gentoo.org> @@ -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() |
