Effortless console text colorization based on user-defined patterns in Python."
Project description
ColorPattern is a Python module designed for enhancing text output in the console by applying color to specific patterns. It offers a flexible way to define patterns and apply different text colors, background colors, styles, and underlines to matching text in the output.
Installation
You can install ColorPattern using pip:
pip install colorpattern
USAGE
from colorpattern import SetPattern, start_color
# Define color patterns
pattern1 = SetPattern(r'\d+', color='green', back='black', style='bright', underline=True)
pattern2 = SetPattern(r'error', color='red', back='yellow', style='dim', underline=False)
pattern3 = SetPattern(r'pattern', back='blue', style='reset_all', underline=True)
# Initialize color for patterns
start_color([pattern1, pattern2, pattern3])
# Your code with colorized output
print("123 error 456 pattern")
Patterns
pattern: Regular expression pattern to match in the text.
color: Text color (e.g., ‘green’, ‘red’, ‘yellow’).
back: Background color (e.g., ‘black’, ‘blue’, ‘white’).
style: Text style (e.g., ‘bright’, ‘dim’, ‘reset_all’).
underline: Set to True for underlining matched text.
License
This project is licensed under the GNU-GLP,3 License - see the LICENSE file for details.
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
Hashes for colorpattern-1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9abc723e9cb03a96068a29bb2282b9fdea5b5ad97c64a9d77678e17f9307bc5 |
|
MD5 | 7930d47f4d8a6067c8f4cbc321c603a8 |
|
BLAKE2b-256 | 061fb1dbefb26fa31f3162372296805d8b58243105e11000cca1d5a861c39921 |