1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

[output] use ANSI colors only when stream is a TTY

This commit is contained in:
Mike Fährmann 2024-10-28 14:59:54 +01:00
parent ee61256054
commit 76f855d87b
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -33,15 +33,18 @@ except Exception:
TTY_STDIN = False
COLORS_DEFAULT = {}
COLORS = not os.environ.get("NO_COLOR")
COLORS_DEFAULT = {
"success": "1;32",
"skip" : "2",
"debug" : "0;37",
"info" : "1;37",
"warning": "1;33",
"error" : "1;31",
} if COLORS else {}
if COLORS:
if TTY_STDOUT:
COLORS_DEFAULT["success"] = "1;32"
COLORS_DEFAULT["skip"] = "2"
if TTY_STDERR:
COLORS_DEFAULT["debug"] = "0;37"
COLORS_DEFAULT["info"] = "1;37"
COLORS_DEFAULT["warning"] = "1;33"
COLORS_DEFAULT["error"] = "1;31"
if util.WINDOWS:
ANSI = COLORS and os.environ.get("TERM") == "ANSI"