sparc.utils module
Utilities that are loosely related to core sparc functionalities
- exception sparc.utils.ProcessReturned[source]
Bases:
Exception
Simple class for process that has returned
- sparc.utils.cprint(content, color=None, bold=False, underline=False, **kwargs)[source]
Color print wrapper for ansi terminal. Only a few color names are provided
- sparc.utils.locate_api(json_file=None, doc_path=None, cfg=<ase.config.Config object>)[source]
Locate the SPARC API setup file with the following priority: 1) If json_file is provided (either from parameter or cfg), use it directly. 2) If doc_path is provided:
Function parameter takes precedence.
Environment variable SPARC_DOC_PATH comes next.
Configuration section [sparc] in the ini file is the last resort.
If both json_file and doc_path are provided, raise an exception.
Fallback to the default API setup if neither is provided.
- sparc.utils.monitor_process(self, interval=1.0)[source]
Usage: try:
- with monitor_process(process):
do_something()
- except TimeoutException:
raise
- sparc.utils.sanitize_path(path_string)[source]
Sanitize path containing string in UNIX systems Returns a PosixPath object
It is recommended to use this sanitize function before passing any path-like strings from cfg parser