colourise

Note

This module requires click, which pip users can install with the jnrbase[colour] requirement.

Constants

jnrbase.colourise.COLOUR = True

Global flag to disable all colourisation

Functions

jnrbase.colourise._colourise(text, colour)[source]

Colour text, if possible.

Parameters
  • text (str) – Text to colourise

  • colour (str) – Colour to display text in

Return type

str

Returns

Colourised text, if possible

Text formatting

jnrbase.colourise.fail(__text)[source]

Format a failure message.

Parameters

__text (str) – Text to format

Return type

str

Returns

Bright red text, if possible

jnrbase.colourise.info(__text)[source]

Format an informational message.

Parameters

__text (str) – Text to format

Return type

str

Returns

Bright blue text, if possible

jnrbase.colourise.success(__text)[source]

Format a success message.

Parameters

__text (str) – Text to format

Return type

str

Returns

Bright green text, if possible

jnrbase.colourise.warn(__text)[source]

Format a warning message.

Parameters

__text (str) – Text to format

Return type

str

Returns

Bright yellow text, if possible

Message formatting

jnrbase.colourise.pfail(__text)[source]

Pretty print a failure message to stderr.

Parameters

__text (str) – Text to print

Return type

None

jnrbase.colourise.pinfo(__text)[source]

Pretty print an informational message to stdout.

Parameters

__text (str) – Text to print

Return type

None

jnrbase.colourise.psuccess(__text)[source]

Pretty print a success message to stdout.

Parameters

__text (str) – Text to print

Return type

None

jnrbase.colourise.pwarn(__text)[source]

Pretty print a warning message to stderr.

Parameters

__text (str) – Text to print

Return type

None

Examples

Text formatting

>>> fail('Error!')
'Error!'
>>> info('Cats are not dogs')
'Cats are not dogs'
>>> success('Excellent')
'Excellent'
>>> warn('Ick')
'Ick'