colour_filter module and colour-filter command - colour parts of lines
colour-filter command
The colour-filter command reads lines from its input,
colours parts of the line and prints the result on its output.
For example colour the output of a build script. Colour Info: in green
and all of the line that starts Error: in red.
$ ./build.sh 2>&1 | colour-filter '^Info:' green 'Error:.*' red
colour_filter module
ColourFilter class
-
__init__()Create instance of ColourFilter.
-
enableDebug( enable=True )Turn on the debug output to help understand why patterns are not matching as expected.
-
define( pattern, colour )When the regular express
patternis found in a line of input colour it ascolouron the output.colouris either the string name of a list colour name seperated by ':' or ';'. E.g.'red'or 'red;bg-white'The builtin foreground colour names are:
bold, black, brown, green, yellow, blue, magenta, cyan, gray, red, lightred, lightgreen, lightyellow, lightblue, lightmagenta, lightcyan ans white.The builtin background colour names are:
bg-black, bg-brown, bg-green, bg-yellow, bg-blue, bg-magenta, bg-cyan, bg-gray and bg-white. -
filterLines( input_file, output_file, line_buffered )Read lines from
input_fileuntil end-of-file. Replace all matching patterns with their defined colour. Write each converted line tooutput_fileand ifline_bufferedisTruecallflush()on theoutput_file.
Example that colours lines of build.log
from colour_filter import ColourFilter
f = ColourFilter()
f.define( 'Info:', 'green' )
f.define( 'Error:', 'red;bg-white' )
with open( 'build.log' ) as input_file:
f.filterLines( input_file, sys.stdout, line_buffered=False )
Metadata
Release files for colour-filter 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| colour-filter-1.1.2.tar.gz | 5.4 kB | Without provenance | Details for colour-filter-1.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| colour_filter-1.1.2-py3-none-any.whl | Python 3 | none | any | Details for colour_filter-1.1.2-py3-none-any.whl |
Total release size: 10.8 kB
Release files / colour-filter-1.1.2.tar.gz
| Download URL | colour-filter-1.1.2.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95883247b4ff394feace505f0d8734ac7d1393285e154282a7ba81d67300c143
|
|
BLAKE2b-256 checksum How to use checksums |
12ecea67c99baa04572993ca53b3ae24f8f3d8fa16cc0e060096c929c8e19bd3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / colour_filter-1.1.2-py3-none-any.whl
| Download URL | colour_filter-1.1.2-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2744883532b4499c8d46703a4fefcf0d4ea7135ddab5148004dacf4fce7281ec
|
|
BLAKE2b-256 checksum How to use checksums |
3ef87c488f69d9184ff1bc1ffd9b42398fe0f592d524a2b7c7e2b4b91916b84d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Security for colour-filter 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.