Prepare lines of text for easy consumption
Project description
See the documentation at https://linecook.readthedocs.io
NOTE: Most of this is just planning, and doesn’t actually work yet.
This was originally designed as a tool to transform logging output into a form that I’d prefer to consume:
$ echo "Can I have a cheeseburger?" | linecook lolcats I can haz cheezburger?
linecook doesn’t actually define way translate lines of text into lolcats, but you could easily define your own:
{
'replacers': {
'request': ['Can I', 'I can'],
'verb': ['have', 'haz'],
'noun': ['cheeseburger', 'cheezburger'],
},
'recipes': {
'lolcats': ['request', 'verb', 'noun'],
},
}
Recipes are just collections of transformations that translate a line of text into another line of text.
- transforms:
A transform is the most generic type of transformation. It’s just a function that takes a string and returns an output string.
- colorizers:
A colorizer is simply a transform that takes a substring match and wraps it with a terminal color.
- replacers:
A replacer is a simple way to specify a transform that replaces a substring pattern with some output text.
- deleters:
A deleter is simply a replacer where the output is an empty string.
- filters:
A filter matches lines of text, which are skipped.
Obviously, this is an incredibly basic (and ridiculous) example. A more useful example colorizes lines of a log file using the following configuration:
{
'colorizers': {
'warn_color': {
'match_pattern': ' WARN ',
'color': 'yellow',
},
'error_color': {
'match_pattern': ' ERROR ',
'on_color': 'on_red',
},
},
'recipes': {
'logs': [
'warn_color',
'error_color',
],
},
}
You can use the
$ tail -f path/to/log.txt | linecook logs
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 linecook-0.1.0.dev0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3763a732b5e444ad876c9737531e1ad33aecf5ecf29b296df833267f96da742c |
|
MD5 | 0294e7ab2c65a632a0845a8afe58bfd1 |
|
BLAKE2b-256 | 753a33d35d34ba855db26d7d88922e8bc26745528ccc404090c96ec7309352ef |