[output] define and use global TTY_STD... values

This commit is contained in:
Mike Fährmann
2024-10-28 14:57:05 +01:00
parent e93b8efe7b
commit ee61256054
2 changed files with 19 additions and 9 deletions

View File

@@ -17,6 +17,22 @@ from . import config, util, formatter
# --------------------------------------------------------------------
# Globals
try:
TTY_STDOUT = sys.stdout.isatty()
except Exception:
TTY_STDOUT = False
try:
TTY_STDERR = sys.stderr.isatty()
except Exception:
TTY_STDERR = False
try:
TTY_STDIN = sys.stdin.isatty()
except Exception:
TTY_STDIN = False
COLORS = not os.environ.get("NO_COLOR")
COLORS_DEFAULT = {
"success": "1;32",
@@ -323,7 +339,7 @@ def select():
if mode is None or mode == "auto":
try:
if sys.stdout.isatty():
if TTY_STDOUT:
output = ColorOutput() if ANSI else TerminalOutput()
else:
output = PipeOutput()