Convenience functions for ANSI terminal colour sequences
Project description
Mapping and function for adding ANSI terminal colour escape sequences to strings for colour highlighting of output.
Function colourise(s, colour=None, uncolour='normal')
Return a string enclosed in colour-on and colour-off ANSI sequences.
colour: names the desired ANSI colour.uncolour: may be used to specify the colour-off colour; the default is 'normal'.
Function colourise_patterns(s, patterns, default_colour=None)
Colourise a string according to patterns.
s: the stringpatterns: a sequence of patternsdefault_colour: if a string pattern has no colon, or starts with a colon, use this colour; default DEFAULT_HIGHLIGHT
Each pattern may be:
- a string of the form "[colour]:regexp"
- a string containing no colon, taken to be a regexp
- a tuple of the form (colour, regexp)
- a regexp object
Returns the string with ANSI colour escapes embedded.
Function make_pattern(pattern, default_colour=None)
Convert a pattern specification into a (colour, regexp) tuple.
Each pattern may be:
- a string of the form "[colour]:regexp"
- a string containing no colon, taken to be a regexp
- a tuple of the form (colour, regexp)
- a regexp object
Function make_patterns(patterns, default_colour=None)
Convert an iterable of pattern specifications into a list of (colour, regexp) tuples.
Each pattern may be:
- a string of the form "[colour]:regexp"
- a string containing no colon, taken to be a regexp
- a tuple of the form (colour, regexp)
- a regexp object
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
File details
Details for the file cs.ansi_colour-20180726.tar.gz.
File metadata
- Download URL: cs.ansi_colour-20180726.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8b6b897ca89972728de154a1e6706dd576e9685111f8e17abf8288660617fdc
|
|
| MD5 |
edf96b899374a63b7a6341767207de2c
|
|
| BLAKE2b-256 |
ab8040faf5783b2204fad791642ab91d9273ebd5abb9d5909e44ed52c1bc1635
|