thepipe.tools

Manipulating time and so…

Module Contents

class thepipe.tools.Timer(message='It', precision=3, callback=print)[source]

A very simple, accurate and easy to use timer context

start(self)[source]

Starts the timers

stop(self)[source]

Stops the timer

property seconds(self)[source]

The elapsed time in seconds

property cpu_seconds(self)[source]

The elapsed CPU time in seconds

log(self)[source]

Call the callback function with the logging message

class thepipe.tools.Cuckoo(interval=0, callback=print)[source]

A timed callback caller, which only executes once in a given interval.

reset(self)[source]

Reset the timestamp

thepipe.tools.ignored(*exceptions)[source]

Ignore-context for a given list of exceptions.

Example:
with ignored(AttributeError):

foo.a = 1

thepipe.tools.peak_memory_usage()[source]

Return peak memory usage in MB

thepipe.tools.ATTRIBUTES[source]
thepipe.tools.ATTRIBUTES_RE[source]
thepipe.tools.HIGHLIGHTS[source]
thepipe.tools.HIGHLIGHTS_RE[source]
thepipe.tools.COLORS[source]
thepipe.tools.COLORS_RE[source]
thepipe.tools.RESET = \033[0m[source]
thepipe.tools.RESET_RE = \033\[0m[source]
thepipe.tools.colored(text, color=None, on_color=None, attrs=None, ansi_code=None)[source]

Colorize text, while stripping nested ANSI color sequences.

Author: Konstantin Lepa <konstantin.lepa@gmail.com> / termcolor

Available text colors:

red, green, yellow, blue, magenta, cyan, white.

Available text highlights:

on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white.

Available attributes:

bold, dark, underline, blink, reverse, concealed.

Example:

colored(‘Hello, World!’, ‘red’, ‘on_grey’, [‘blue’, ‘blink’]) colored(‘Hello, World!’, ‘green’)

thepipe.tools.cprint(text, color=None, on_color=None, attrs=None)[source]

Print colorize text.

Author: Konstantin Lepa <konstantin.lepa@gmail.com> / termcolor

It accepts arguments of print function.

thepipe.tools.isnotebook()[source]

Check if running within a Jupyter notebook

thepipe.tools.supports_color()[source]

Checks if the terminal supports color.