seibuilder.utils package¶
Set of util functions.
Submodules¶
Set of util functions.
- are_we_in_a_notebook() bool[source]¶
Check in which environment we are.
- Returns:
- booleand option:
True: if the script is running inside a Jupyter notebook.
False: if is running in Python or IPython console.
- Return type:
bool
- copy_file(source: str, destination: str, verbose: int = 0)[source]¶
Copy a file in a new destination.
- Parameters:
source (str) – file to copy.
destination (str) – where to copy.
verbose (int, optional) – loudness controller: - 0: print errors - 1: print errors and warnings - 2: print errors, warnings and info - 3: print errors, warnings, info and debugger messages. Defaults to 0.
- Raises:
ValueError – if source file does not exist.
- makedir(path: str, verbose: int = 1)[source]¶
Make a folder function.
- Parameters:
path (str) – directory path.
verbose (int, optional) – loudness controller: - 0: print errors - 1: print errors and warnings - 2: print errors, warnings and info - 3: print errors, warnings, info and debugger messages. Defaults to 1.
- message(msg: str, msg_type: str = 'info', add_date: bool = False, **kwargs)[source]¶
Print on screen useful messages.
- Parameters:
msg (str) – message to print
msg_type (str, optional) – type of message - ‘error’ or ‘e’ : errors messages - ‘warning’ or ‘w’ : warning messages - ‘info’ or ‘i’ : info messages - ‘debug’ or ‘d’ : debug messages. Defaults to “info”.
add_date (bool, optional) – if True show the time. Defaults to False.
- Kwargs:
**kwargs: other
printfunction kwargs
- pytail(file_path: str, n: int = 10, encoding: str = 'utf8') list | None[source]¶
Print last n lines from the file_path.
- Parameters:
file_path (str) – File path.
n (int) – Optional; number of last line to read.
encoding (str) – Optional; character encoding (see: https://docs.python.org/3/howto/unicode.html)
- Returns:
- muliple possible output:
None: The file is empty
list: a list with the last lines.
- Return type:
(list | None)