rez.utils.colorize

class rez.utils.colorize.ColorizedStreamHandler(stream=None)[source]

Bases: logging.StreamHandler

A stream handler for use with the Python logger.

This handler uses the Colorama module to style the log messages based on the rez configuration.

STYLES

A mapping between the Python logger levels and a function that can be used to provide the appropriate styling.

Type

dict

STYLES = {0: <function notset>, 10: <function debug>, 20: <function info>, 30: <function warning>, 40: <function error>, 50: <function critical>}
emit(record)[source]

Emit a record.

If the stream associated with this handler provides tty then the record that is emitted with be formatted to include escape sequences for appropriate styling.

property is_colorized
property is_tty

Return true if the stream associated with this handler is a tty stream.

Returns

bool

class rez.utils.colorize.Printer(buf=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]

Bases: object

get(msg, style=None)[source]
rez.utils.colorize.alias(str_)[source]

Return the string wrapped with the appropriate styling to display a tool alias. The styling will be determined based on the rez configuration.

Parameters

str (str) – The string to be wrapped.

Returns

The string styled with the appropriate escape sequences.

Return type

str

rez.utils.colorize.critical(str_)[source]

Return the string wrapped with the appropriate styling of a critical message. The styling will be determined based on the rez configuration.

Parameters

str (str) – The string to be wrapped.

Returns

The string styled with the appropriate escape sequences.

Return type

str

rez.utils.colorize.debug(str_)[source]

Return the string wrapped with the appropriate styling of a debug message. The styling will be determined based on the rez configuration.

Parameters

str (str) – The string to be wrapped.

Returns

The string styled with the appropriate escape sequences.

Return type

str

rez.utils.colorize.ephemeral(str_)[source]

Return the string wrapped with the appropriate styling to display an ephemeral package. The styling will be determined based on the rez configuration.

Parameters

str (str) – The string to be wrapped.

Returns

The string styled with the appropriate escape sequences.

Return type

str

rez.utils.colorize.error(str_)[source]

Return the string wrapped with the appropriate styling of an error message. The styling will be determined based on the rez configuration.

Parameters

str (str) – The string to be wrapped.

Returns

The string styled with the appropriate escape sequences.

Return type

str

rez.utils.colorize.heading(str_)[source]

Return the string wrapped with the appropriate styling of a heading message. The styling will be determined based on the rez configuration.

Parameters

str (str) – The string to be wrapped.

Returns

The string styled with the appropriate escape sequences.

Return type

str

rez.utils.colorize.implicit(str_)[source]

Return the string wrapped with the appropriate styling to display an implicit package. The styling will be determined based on the rez configuration.

Parameters

str (str) – The string to be wrapped.

Returns

The string styled with the appropriate escape sequences.

Return type

str

rez.utils.colorize.inactive(str_)[source]

Return the string wrapped with the appropriate styling to display something inactive.

Choices are grey, grey or grey.

rez.utils.colorize.info(str_)[source]

Return the string wrapped with the appropriate styling of an info message. The styling will be determined based on the rez configuration.

Parameters

str (str) – The string to be wrapped.

Returns

The string styled with the appropriate escape sequences.

Return type

str

rez.utils.colorize.local(str_)[source]

Return the string wrapped with the appropriate styling to display a local package. The styling will be determined based on the rez configuration.

Parameters

str (str) – The string to be wrapped.

Returns

The string styled with the appropriate escape sequences.

Return type

str

rez.utils.colorize.notset(str_)[source]

Return the string wrapped with the appropriate escape sequences to remove all styling.

Parameters

str (str) – The string to be wrapped.

Returns

The string styled with the appropriate escape sequences.

Return type

str

rez.utils.colorize.stream_is_tty(stream)[source]

Return true if the stream is a tty stream.

Returns

bool

rez.utils.colorize.warning(str_)[source]

Return the string wrapped with the appropriate styling of a warning message. The styling will be determined based on the rez configuration.

Parameters

str (str) – The string to be wrapped.

Returns

The string styled with the appropriate escape sequences.

Return type

str