woob.tools.misc
¶
-
woob.tools.misc.
find_exe
(basename)¶ Find the path to an executable by its base name (such as ‘gpg’).
The executable can be overriden using an environment variable in the form NAME_EXECUTABLE where NAME is the specified base name in upper case.
If the environment variable is not provided, the PATH will be searched both without and with a “.exe” suffix for Windows compatibility.
If the executable can not be found, None is returned.
-
woob.tools.misc.
get_backtrace
(empty='Empty backtrace.')¶ Try to get backtrace as string. Returns “Error while trying to get backtrace” on failure.
-
woob.tools.misc.
get_bytes_size
(size, unit_name)¶ Converts a unit and a number into a number of bytes.
>>> get_bytes_size(2, 'KB') 2048.0
-
woob.tools.misc.
input
(prompt=None, /)¶ Read a string from standard input. The trailing newline is stripped.
The prompt string, if given, is printed to standard output without a trailing newline before reading input.
If the user hits EOF (*nix: Ctrl-D, Windows: Ctrl-Z+Return), raise EOFError. On *nix systems, readline is used if available.
-
woob.tools.misc.
iter_fields
(obj)¶
-
woob.tools.misc.
limit
(iterator, lim)¶ Iterate on the lim first elements of iterator.
-
woob.tools.misc.
to_unicode
(text)¶ >>> to_unicode('ascii') == u'ascii' True >>> to_unicode(u'utf\xe9'.encode('UTF-8')) == u'utf\xe9' True >>> to_unicode(u'unicode') == u'unicode' True