Determine if terminal output should be colored, respecting environment variables
Reason this release was yanked:
apply_bold doesn't work
Project description
should-color
Determine if terminal output should be colored, respecting NO_COLOR and CLICOLOR environment variables.
On Unix, ANSI colors are enabled if the output is isatty. On Windows, ANSI colors are assumed to be unsupported unless or colorama is installed and enabled.
Example Usage
import sys
from should_color import should_color, apply_ansi_style
should_color(sys.stdout)
should_color(sys.stderr)
should_color('stdout') # same as should_color(sys.stdout)
should_color('stderr') # same as should_color(sys.stdout)
print(
apply_ansi_style(
"ERROR:",
color="red",
bold=True,
# implicitly checks should_color('stdout'),
# both these options are the implicit defaults if unspecified
enabled='auto',
file='stdout',
),
"Fatal problem",
)
License
Licensed under either the Apache 2.0 License or MIT License at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file should_color-0.2.1.tar.gz.
File metadata
- Download URL: should_color-0.2.1.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aeb5d447acb2f31cc247204d422b6fdb252a9b92b599dac2bd7f158b198e5d02
|
|
| MD5 |
fe5c7a97a7a0a668cb0bdf97a30b3e77
|
|
| BLAKE2b-256 |
6ce650ea0af0b9aa4e785c20d9f7bd37f397c1e7b8655e9affc0095a758cbe11
|
File details
Details for the file should_color-0.2.1-py3-none-any.whl.
File metadata
- Download URL: should_color-0.2.1-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4de9987ab4d6f9a33fc3a405ede30d6eb10339de1e99024351c148304245cb6b
|
|
| MD5 |
d82003d3fe89d61586ccc008ce41af89
|
|
| BLAKE2b-256 |
6f6f2d087ec3fa0ee0e2c4ba8a834c9990b421b1fb40dbe356189d89200d2f4c
|