Ascii text color code tagging for python prints and logs
Project description
QuickColor
QuickColor is a Python library providing tags for color formatting sections of printable content. The tags can be flexibly used as part of any string as they simply resolve to the ASCII color codes interpreted by your terminal or terminal emulator.
Installation
Use the package manager pip to install quickcolor.
pip install quickcolor
Library Usage For Color Application
from quickcolor.color_def import color
# colorize printable content
print(f"{color.CGREEN2}This text is bold green{color.CEND}")
from quickcolor.color_def import colors
# alternate method to colorize printable content
print(f"Formatting this phrase part to {colors.fg.yellow}display yellow{colors.off}")
Library Usage For Color Stripping
from quickcolor.color_filter import strip_ansi_esc_sequences_from_string
testString = f'{color.CYELLOW2}Yellow String!{color.CEND}'
print(testString)
print(f'No longer a {strip_ansi_esc_sequences_from_string(testString)}')
from quickcolor.color_filter import strip_ansi_esc_sequences_from_input
testString = f'{color.CBLUE2}Blue String!{color.CEND}'
testBytes = testString.encode(encoding="utf-8")
print(testString)
print(testBytes)
print(f'No longer a {strip_ansi_esc_sequences_from_input(stringOrBytes = testBytes)}')
CLI Utility
The following CLI is included with this package for visualizing available color fields and code combinations.
# qc -h
usage: qc [-h] {shell.colors,color.fields,strip.color.string,strip.color.input} ...
-.-.-. Color attributes for python scripts
positional arguments:
{shell.colors,color.fields,strip.color.string,strip.color.input}
shell.colors display a color chart for current shell
color.fields display class color fields
strip.color.string strip color codes from a string
strip.color.input strip color codes from a byte input
options:
-h, --help show this help message and exit
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
License
Acknowledgements
Inspiration for the color names came from this StackOverflow reply. The color grid method inspiration came from this StackOverflow reply. The regex content for the strip methods are also floting around StackOverflow.
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
File details
Details for the file quickcolor-0.1.3.tar.gz
.
File metadata
- Download URL: quickcolor-0.1.3.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15fa9009c2afd04c8854e6dc26329ae73331771f136decd6bb1e45c0f9ef3fe2 |
|
MD5 | 573701281b4e734682a254351aa59b89 |
|
BLAKE2b-256 | 9c6e0d116178ef531093a71db23dc26614edf0714842a4c3a2f2dc45c5ba9a6c |
File details
Details for the file quickcolor-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: quickcolor-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 253f39e9876b8eef0a0bf697d4cde984321e777693a0dcb8145117c82ee1135e |
|
MD5 | f9226bac1c3295e2e65501aeb5c808ef |
|
BLAKE2b-256 | 05186ef4b2da5df8ff4a3b423b791ee3858e91d4dcd24880cdb033a2d2130840 |