rez.utils.colorize#

rez.utils.colorize.colorama_wrap(stream)#

Wrap the stream with colorama so that it can display colors on any OS

rez.utils.colorize.stream_is_tty(stream)#

Return true if the stream is a tty stream.

Returns:

bool

rez.utils.colorize.critical(str_)#

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.error(str_)#

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.warning(str_)#

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

rez.utils.colorize.info(str_)#

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.debug(str_)#

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.heading(str_)#

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.local(str_)#

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.implicit(str_)#

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.ephemeral(str_)#

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.alias(str_)#

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.inactive(str_)#

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

Choices are grey, grey or grey.

rez.utils.colorize.notset(str_)#

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

class rez.utils.colorize.ColorizedStreamHandler#

Bases: 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 = {0: <function notset>, 10: <function debug>, 20: <function info>, 30: <function warning>, 40: <function error>, 50: <function critical>}#

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

__init__(stream=None)#

Initialize the handler.

If stream is not specified, sys.stderr is used.

property is_tty#

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

Returns:

bool

property is_colorized#
emit(record)#

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.

acquire()#

Acquire the I/O thread lock.

addFilter(filter)#

Add the specified filter to this handler.

close()#

Tidy up any resources used by the handler.

This version removes the handler from an internal map of handlers, _handlers, which is used for handler lookup by name. Subclasses should ensure that this gets called from overridden close() methods.

createLock()#

Acquire a thread lock for serializing access to the underlying I/O.

filter(record)#

Determine if a record is loggable by consulting all the filters.

The default is to allow the record to be logged; any filter can veto this and the record is then dropped. Returns a zero value if a record is to be dropped, else non-zero.

Changed in version 3.2: Allow filters to be just callables.

flush()#

Flushes the stream.

format(record)#

Format the specified record.

If a formatter is set, use it. Otherwise, use the default formatter for the module.

get_name()#
handle(record)#

Conditionally emit the specified logging record.

Emission depends on filters which may have been added to the handler. Wrap the actual emission of the record with acquisition/release of the I/O thread lock. Returns whether the filter passed the record for emission.

handleError(record)#

Handle errors which occur during an emit() call.

This method should be called from handlers when an exception is encountered during an emit() call. If raiseExceptions is false, exceptions get silently ignored. This is what is mostly wanted for a logging system - most users will not care about errors in the logging system, they are more interested in application errors. You could, however, replace this with a custom handler if you wish. The record which was being processed is passed in to this method.

property name#
release()#

Release the I/O thread lock.

removeFilter(filter)#

Remove the specified filter from this handler.

setFormatter(fmt)#

Set the formatter for this handler.

setLevel(level)#

Set the logging level of this handler. level must be an int or a str.

setStream(stream)#

Sets the StreamHandler’s stream to the specified value, if it is different.

Returns the old stream, if the stream was changed, or None if it wasn’t.

set_name(name)#
terminator = '\n'#
class rez.utils.colorize.Printer#

Bases: object

__init__(buf=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)#
get(msg, style=None)#