progressbar.env module¶
- class progressbar.env.ColorSupport(*values)[source]¶
Bases:
IntEnumColor support for the terminal.
- NONE = 0¶
- WINDOWS = 8¶
- XTERM = 16¶
- XTERM_256 = 256¶
- XTERM_TRUECOLOR = 16777216¶
- classmethod from_env() ColorSupport[source]¶
Get the color support from the environment.
If any of the environment variables contain 24bit or truecolor, we will enable true color/24 bit support. A TERM that is itself a truecolor terminal (see TRUECOLOR_TERMS) also enables 24 bit support. If they contain 256, we will enable 256 color/8 bit support. If they match a known ANSI terminal (see ANSI_TERM_RE, e.g. xterm-color, screen, tmux, konsole, rxvt, linux), we will enable 16 color support. Otherwise, we assume no color support.
If JUPYTER_COLUMNS or JUPYTER_LINES or JPY_PARENT_PID is set, we will assume true color support.
Note that the highest available value will be used! Having COLORTERM=truecolor will override TERM=xterm-256color.
- progressbar.env.TRUECOLOR_TERMS: frozenset[str] = frozenset({'xterm-ghostty', 'xterm-kitty'})¶
TERM values that on their own guarantee a truecolor-capable terminal, so 24-bit color still engages when
COLORTERMis stripped (e.g. over ssh or sudo). Limited to names that are the terminal; generic values such asxterm-256colorare used by plenty of 256-only emulators.
- progressbar.env.env_flag(name: str, default: bool) bool[source]¶
- progressbar.env.env_flag(name: str, default: bool | None = None) bool | None
Accepts environt variables formatted as y/n, yes/no, 1/0, true/false, on/off, and returns it as a boolean.
If the environment variable is not defined, or has an unknown value, returns default