pylav.helpers.format package#

Submodules#

pylav.helpers.format.ascii module#

class pylav.helpers.format.ascii.EightBitANSI[source]#

Bases: object

Eight-bit ANSI escape sequences.

background#

alias of _BackgroundColourCodes

black = '30'#
blue = '34'#
bold = '1'#
classmethod closest_color(red, green, blue)[source]#

Get the closest 4-bit ANSI colour from a given RGB value.

classmethod closest_from_hex(value)[source]#

Get the closest 4-bit ANSI colour from a given hex value.

classmethod closest_from_rgb(r, g, b)[source]#

Get the closest 4-bit ANSI colour from a given RGB value.

classmethod colorize(text, color, bold=False, underline=False, background=None, italic=False)[source]#

Colorize a string with ANSI escape sequences.

cyan = '36'#
default = '39'#
escape = '\x1b['#
green = '32'#
italic = '3'#
magenta = '35'#
normal = '0'#
classmethod paint_black(text, bold=False, underline=False, background=None, italic=False)[source]#

Paint a string black.

classmethod paint_blue(text, bold=False, underline=False, background=None, italic=False)[source]#

Paint a string blue.

classmethod paint_cyan(text, bold=False, underline=False, background=None, italic=False)[source]#

Paint a string cyan.

classmethod paint_green(text, bold=False, underline=False, background=None, italic=False)[source]#

Paint a string green.

classmethod paint_magenta(text, bold=False, underline=False, background=None, italic=False)[source]#

Paint a string magenta.

classmethod paint_red(text, bold=False, underline=False, background=None, italic=False)[source]#

Paint a string red.

classmethod paint_white(text, bold=False, underline=False, background=None, italic=False)[source]#

Paint a string white.

classmethod paint_yellow(text, bold=False, underline=False, background=None, italic=False)[source]#

Paint a string yellow.

red = '31'#
reset = '0'#
underline = '4'#
white = '37'#
yellow = '33'#

pylav.helpers.format.strings module#

pylav.helpers.format.strings.format_time_dd_hh_mm_ss(duration)[source]#

Formats to the given time in milliseconds into DD:HH:MM:SS

pylav.helpers.format.strings.format_time_string(seconds)[source]#

Formats the given seconds into a time string

Examples

60 -> 1 minute 3600 -> 1 hour 3601 -> 1 hour 1 second 86400 -> 1 day 86401 -> 1 day 1 second

pylav.helpers.format.strings.shorten_string(string, max_length, right=True)[source]#

Shortens the given string to the given max length and adds an ellipsis.

Module contents#