pcvs.helpers.log module
- class pcvs.helpers.log.IOManager(verbose=0, enable_unicode=True, length=80, logfile=None, tty=True)[source]
Bases:
object
Manager for Input/Output streams.
Contains methods for logging and printing in PCVS. IOManager handles multiple outputs (file + standard output), logging levels (warning, error, info, etc) and pretty banners. Colors are handled by click and color tags are written in files (use less -r).
- Parameters
- capture_exception(e_type, user_func=None)[source]
wraps functions to capture unhandled exceptions for high-level function not to crash. :param *e_type: errors to be caught
- color_list = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'bright_black', 'bright_red', 'bright_green', 'bright_yellow', 'bright_blue', 'bright_magenta', 'bright_cyan', 'bright_white']
- enable_unicode(e=True)[source]
enables/disables unicode alphabet usage
- Parameters
e (bool, optional) – True to enable unicode usage, defaults to True
- print_item(s, depth=1, out=True, with_bullet=True)[source]
prints an item
- Parameters
- Returns
item string if out=False, Nothing otherwise
- Return type
- print_short_banner(string=False)[source]
prints a little banner
- Parameters
string (bool) – True if the banner has to be returned, False if it has to be logged
- set_logfile(enable, logfile=None)[source]
setter for logfile path
- Parameters
logfile (str, optional) – logfile name, defaults to None
- special_chars = {'ascii': {'copy': '(c)', 'empty_pg': '-', 'fail': 'X', 'full_pg': '#', 'git': '(git)', 'hdr': '=', 'item': '*', 'none': '-', 'sec': '#', 'sep_h': '-', 'sep_v': ' | ', 'star': '*', 'succ': 'V', 'time': '(time)'}, 'unicode': {'copy': '©', 'empty_pg': '\x1b[90m\x1b[1m○\x1b[0m', 'fail': '✘', 'full_pg': '\x1b[36m\x1b[1m●\x1b[0m', 'git': '⍿', 'hdr': '⎼', 'item': '⟢', 'none': '∅', 'sec': '❖', 'sep_h': '⎼', 'sep_v': ' ⍿ ', 'star': '★', 'succ': '✔', 'time': '⌚'}}
- style(*args, **kwargs)[source]
returns a string style using click
- Returns
a string style
- Return type
click.style
- property tty
getter for tty information
- Returns
False if tty not used, 1 if tty used
- Return type
- utf(k)[source]
returns the corresponding character to a bullet character
- Parameters
k (char) – character used as bullet character
- Returns
fancy bullet character
- Return type
char
- verb_levels = [(0, 'normal'), (1, 'info'), (2, 'debug')]
- pcvs.helpers.log.init(v=0, e=False, l=100, quiet=False)[source]
initializes a global manager for everyone to use
- pcvs.helpers.log.pretty_print_exception(e: GenericError)[source]
Display exceptions in a fancy way.
- Parameters
e (exceptions.GenericError.) – the execption to print
- pcvs.helpers.log.progbar(it, print_func=None, man=None, **kargs)[source]
prints a progress bar using click
- Parameters
it (iterable) – iterable on which the progress bar has to iterate
print_func (function, optional) – method used to show the item next to the progress bar, defaults to None
man (log.IOManager, optional) – manager used to describe the bullets, defaults to None
- Returns
a click progress bar (iterable)
- Return type
click.ProgressBar