diff --git a/scripts/wk/log.py b/scripts/wk/log.py index 13934b0d..e2ee6336 100644 --- a/scripts/wk/log.py +++ b/scripts/wk/log.py @@ -8,7 +8,7 @@ import pathlib import shutil import time -from . import cfg +from wk import cfg # Functions diff --git a/scripts/wk/std.py b/scripts/wk/std.py index 3257210d..7905ce86 100644 --- a/scripts/wk/std.py +++ b/scripts/wk/std.py @@ -255,7 +255,20 @@ def beep(repeat=1): def bytes_to_string(size, decimals=0, use_binary=True): - """Convert size into a human-readable format, returns str.""" + """Convert size into a human-readable format, returns str. + + [Doctest] + >>> bytes_to_string(10) + '10 B' + >>> bytes_to_string(10_000_000) + '10 MiB' + >>> bytes_to_string(10_000_000, decimals=2) + '9.54 MiB' + >>> bytes_to_string(10_000_000, decimals=2, use_binary=False) + '10.00 MB' + >>> bytes_to_string(-10_000_000, decimals=4) + '-9.5367 MiB' + """ LOG.debug( 'size: %s, decimals: %s, use_binary: %s', size, @@ -414,7 +427,16 @@ def format_function_output(output, indent=INDENT, width=WIDTH): def get_exception(name): - """Get exception by name, returns exception object.""" + """Get exception by name, returns exception object. + + [Doctest] + >>> get_exception('AttributeError') + + >>> get_exception('CalledProcessError') + + >>> get_exception('GenericError') + + """ LOG.debug('Getting exception: %s', name) try: obj = getattr(sys.modules[__name__], name)