saturnin.lib.console

Saturnin console manager for terminal configuration and output.

Globals

saturnin.lib.console.console: ConsoleManager

Saturnin site manager

saturnin.lib.console.highlighter: SaturninHighlighter

Saturnin text highlighter

Parameters:

text (str | Text) –

Return type:

Text

saturnin.lib.console.DEFAULT_THEME: Theme = <rich.theme.Theme object>

Default console theme

Constants

saturnin.lib.console.FORCE_TERMINAL: bool = None

Use rich terminal or not

saturnin.lib.console.RICH_YES: Text = <text '✔' []>

Standard rich text for YES

saturnin.lib.console.RICH_NO: Text = <text '✖' []>

Standard rich text for NO

saturnin.lib.console.RICH_OK: Text = <text 'OK' []>

Standard rich text for OK

saturnin.lib.console.RICH_WARNING: Text = <text 'WARNING' []>

Standard rich text for WARNING

saturnin.lib.console.RICH_ERROR: Text = <text 'ERROR' []>

Standard rich text for ERROR

Functions

saturnin.lib.console._h

Shortcut to highlighter.highlight

Parameters:

text (Text) –

Return type:

Text

Classes

class saturnin.lib.console.ConsoleManager[source]

Bases: object

Saturnin site manager.

print(message='', end='\n') None[source]

Prints message to console.

Return type:

None

print_error(message) None[source]

Prints error message to error console.

Return type:

None

print_exception() None[source]

Prints exception to error console.

Return type:

None

print_info(message='') None[source]

Prints information message to console.

Return type:

None

err_console: Console

Rich error console

quiet: bool

Suppress output flag

std_console: Console

Rich main console

verbose: bool

Verbose output flag

class saturnin.lib.console.SaturninHighlighter[source]

Bases: RegexHighlighter

Highlights our special options.

highlight(text: Text) Text[source]

Highlight Text using regular expressions.

Parameters:

text (Text) – Text to highlighted.

Return type:

Text

highlights: List[str] = ['(^|\\W)(?P<switch>\\-\\w+)(?![a-zA-Z0-9])', '(^|\\W)(?P<option>\\-\\-[\\w\\-]+)(?![a-zA-Z0-9])', '(?P<metavar>\\<[^\\>]+\\>)', '(?P<section>\\n[A-Z][^:\\n]*(:)\\s?)', '^(?P<year>[0-9]{4})-(?P<month>1[0-2]|0[1-9])$', '^(?P<date>(?P<year>[0-9]{4})(?P<month>1[0-2]|0[1-9])(?P<day>3[01]|0[1-9]|[12][0-9]))$', '^(?P<date>(?P<year>[0-9]{4})-?(?P<day>36[0-6]|3[0-5][0-9]|[12][0-9]{2}|0[1-9][0-9]|00[1-9]))$', '^(?P<date>(?P<year>[0-9]{4})-?W(?P<week>5[0-3]|[1-4][0-9]|0[1-9]))$', '^(?P<date>(?P<year>[0-9]{4})-?W(?P<week>5[0-3]|[1-4][0-9]|0[1-9])-?(?P<day>[1-7]))$', '^(?P<time>(?P<hour>2[0-3]|[01][0-9]):?(?P<minute>[0-5][0-9]))$', '^(?P<time>(?P<hour>2[0-3]|[01][0-9])(?P<minute>[0-5][0-9])(?P<second>[0-5][0-9]))$', '^(?P<timezone>(Z|[+-](?:2[0-3]|[01][0-9])(?::?(?:[0-5][0-9]))?))$', '^(?P<time>(?P<hour>2[0-3]|[01][0-9])(?P<minute>[0-5][0-9])(?P<second>[0-5][0-9]))(?P<timezone>Z|[+-](?:2[0-3]|[01][0-9])(?::?(?:[0-5][0-9]))?)$', '^(?P<date>(?P<year>[0-9]{4})(?P<hyphen>-)?(?P<month>1[0-2]|0[1-9])(?(hyphen)-)(?P<day>3[01]|0[1-9]|[12][0-9])) (?P<time>(?P<hour>2[0-3]|[01][0-9])(?(hyphen):)(?P<minute>[0-5][0-9])(?(hyphen):)(?P<second>[0-5][0-9]))$', '^(?P<date>(?P<year>-?(?:[1-9][0-9]*)?[0-9]{4})-(?P<month>1[0-2]|0[1-9])-(?P<day>3[01]|0[1-9]|[12][0-9]))(?P<timezone>Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9])?$', '^(?P<time>(?P<hour>2[0-3]|[01][0-9]):(?P<minute>[0-5][0-9]):(?P<second>[0-5][0-9])(?P<frac>\\.[0-9]+)?)(?P<timezone>Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9])?$', '^(?P<date>(?P<year>-?(?:[1-9][0-9]*)?[0-9]{4})-(?P<month>1[0-2]|0[1-9])-(?P<day>3[01]|0[1-9]|[12][0-9]))T(?P<time>(?P<hour>2[0-3]|[01][0-9]):(?P<minute>[0-5][0-9]):(?P<second>[0-5][0-9])(?P<ms>\\.[0-9]+)?)(?P<timezone>Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9])?$', '(?P<ipv4>[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3})|(?P<ipv6>([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4})|(?P<eui64>(?:[0-9A-Fa-f]{1,2}-){7}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{1,2}:){7}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{4}\\.){3}[0-9A-Fa-f]{4})|(?P<eui48>(?:[0-9A-Fa-f]{1,2}-){5}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{1,2}:){5}[0-9A-Fa-f]{1,2}|(?:[0-9A-Fa-f]{4}\\.){2}[0-9A-Fa-f]{4})|(?P<uuid>[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})|(?P<uuid2>[a-fA-F0-9]{32})|(?P<call>[\\w.]*?)\\(|\\b(?P<bool_true>True)\\b|\\b(?P<bool_false>False)\\b|\\b(?P<py_none>None)\\b|(?P<ellipsis>\\.\\.\\.)|(?P<number_complex>(?<!\\w)(?:\\-?[0-9]+\\.?[0-9]*(?:e[-+]?\\d+?)?)(?:[-+](?:[0-9]+\\.?[0-9]*(?:e[-+]?\\d+)?))?j)|(?P<number>(?<!\\w)\\-?[0-9]+\\.?[0-9]*(e[-+]?\\d+?)?\\b|0x[0-9a-fA-F]*)|(?P<path>\\B(/[-\\w._+]+)*\\/)(?P<filename>[-\\w._+]*)?|(?<![\\\\\\w])(?P<str>b?\'\'\'.*?(?<!\\\\)\'\'\'|b?\'.*?(?<!\\\\)\'|b?\\"\\"\\".*?(?<!\\\\)\\"\\"\\"|b?\\".*?(?<!\\\\)\\")|(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#]*)|(?P<zmq_address>(inproc|ipc|tcp|pgm|epgm|vmci)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#]*)|(?P<mime>(application|audio|font|example|image|message|model|multipart|text|video|x-(?:[0-9A-Za-z!#$%&\'*+.^_`|~-]+))/([0-9A-Za-z!#$%&\'*+.^_`|~-]+))(?P<mime_param>((?:[ \\t]*;[ \\t]*[0-9A-Za-z!#$%&\'*+.^_`|~-]+=(?:[0-9A-Za-z!#$%&\'*+.^_`|~-]+|\\"(?:[^\\"\\\\\\\\]|\\\\.)*\\"))*))|(?P<enum>\\b[A-Z_]*\\b)|(?P<email>[.\\w-]+@([\\w-]+\\.)+[\\w-]+)']

Regular expressions used by highlight.