mass.util.util

Contains utility functions to assist in various mass functions.

Module Contents

Classes

ColorFormatter

Colored Formatter for logging output.

Functions

show_versions()

Print dependency information.

ensure_iterable(item)

Ensure the given item is an returned as an iterable.

ensure_non_negative_value(value[, exclude_zero])

Ensure provided value is a non-negative value, or None.

Attributes

LOG_COLORS

Contains logger levels and corresponding color codes.

mass.util.util.LOG_COLORS[source]

Contains logger levels and corresponding color codes.

Type

dict

mass.util.util.show_versions()[source]

Print dependency information.

mass.util.util.ensure_iterable(item)[source]

Ensure the given item is an returned as an iterable.

Parameters

item (object) – The item to ensure is returned as an iterable.

mass.util.util.ensure_non_negative_value(value, exclude_zero=False)[source]

Ensure provided value is a non-negative value, or None.

Parameters

value (float) – The value to ensure is non-negative

Raises

ValueError – Occurs if the value is negative.

class mass.util.util.ColorFormatter(fmt=None, datefmt=None, style='%')[source]

Bases: logging.Formatter

Colored Formatter for logging output.

Based on http://uran198.github.io/en/python/2016/07/12/colorful-python-logging.html

format(record, *args, **kwargs)[source]

Set logger format.