Colorize
Give some color to your (remote) TTY!!
VERSION |
DOWNLOADS |
TESTS |
COVERAGE |
WHEEL |
|---|---|---|---|---|
And it is free. Checkout the Source code.
Installation and Usage
Two options: to install it in your system/project:
pip install colorize
And you can use it with:
python -m colorize -h
Now, you have two ways to use it:
Rendering the output
Just execute:
$ command to execute | python -m colorize
If you need to render both the stdout and the stderr:
$ command to execute |& python -m colorize
This method works well with too long outputs
As runner
Other way to use it:
$ python -m colorize command to execute
This method can do disgusting things with too long outputs.
Options
You can change the output format with the argument -f or --format. It uses the same format that logging, so you can use any of its special variables, like:
%(asctime)s, to show the time.%(message)s, to show the message itself.%(msecs)d, to show the relative time.
You can combine them as you wish. Example:
$ python -m colorize -- echo foo foo $ python -m colorize -f "%(asctime)s - %(levelname).2s: %(message)s" -- echo foo 05-29 08:43:09 - IN: foo $ python -m colorize -f "%(levelname).2s %(asctime)s - %(message)s" -- echo foo IN 05-29 08:44:17 - foo
Default date format is %m-%d %H:%M:%S, but you can change it with --date-format:
$ python -m colorize -f "%(asctime)s" --date-format="%H:%M:%S" -- echo foo 08:44:17 $ python -m colorize -f "%(asctime)s" --date-format="%H %M %S" -- echo foo 08 44 17
Configuration File
It will find a configuration file in the current directory, in the home directory or in the default path directory. The first one found will be used. So, it will search for:
./.colorize.conf
$HOME/.configuration/colorize/colorize.conf
/etc/colorize/colorize.conf
The format for this file is very easy: it is a CSV file with next fields:
# regular expression to highlight (quoted) , bold output , foreground color , background color "^=+$" , 1 , white , "^=+$" , true , white , black "^=+$" , 0 , red , white "^=+$" , false , brown , magenta
For example, you can configure it to colorize the go test output:
"^PASS", 1, white, green "^ok", 1, white, green "^FAIL", 1, white, red "^--- FAIL:", 1, white, red
Available colors:
blackwhiteredgreenbluebrowngraymagentacyan
And that’s all.
Example to simulate colordiff
To emulate colordiff, just use this configuration file:
"^>.*", 0, blue "^<.*", 0, red "^\d+,?\d*c\d+,?\d*$", 0, magenta
That’s enough :D
Metadata
Release files for colorize 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| colorize-1.1.0.tar.gz | 6.4 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| colorize-1.1.0-py3.6.egg | Legacy Egg format | - | - | Details |
| colorize-1.1.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 28.4 kB
Release files / colorize-1.1.0.tar.gz
| Download URL | colorize-1.1.0.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
650cf4d28d0442ed5409a1b769f80814da4b7c447fab6b630e81bee15ee990db
|
|
BLAKE2b-256 checksum How to use checksums |
37b753533b7467d2d261429e927a467041ed81d41dd608268295460a41876e80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.6
|
Release files / colorize-1.1.0-py3.6.egg
| Download URL | colorize-1.1.0-py3.6.egg |
|---|---|
| Size | 14.5 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
7c2695611e76b5a772a07b462be60d1c129bb5e84c86236c813fc0cd77799fd2
|
|
BLAKE2b-256 checksum How to use checksums |
1d0cab4224d76706cf335661b1319110326f89e4c4ea60dc1ee9dbea06133995
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.6
|
Release files / colorize-1.1.0-py2.py3-none-any.whl
| Download URL | colorize-1.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
8ded772e7e08a09ef11d14f007669bc0b5adacd0aef84689f5daa81403508bf5
|
|
BLAKE2b-256 checksum How to use checksums |
d7361de7e2ef3b2a70b0ef58f17f5f9c25dddc1092560934d60086836286a5ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/3.6
|