safe.util¶
No project is complete without a utility module.
| author: | Joe Joyce <joe@decafjoe.com> |
|---|---|
| copyright: | Copyright (c) Joe Joyce and contributors, 2016-2019. |
| license: | BSD |
-
safe.util.expand_path(path)[source]¶ Return absolute path, with variables and
~expanded.Parameters: path (str) – Path, possibly with variables and ~Returns: Absolute path with special sequences expanded Return type: str
-
safe.util.get_executable(name)[source]¶ Return the full path to executable named
name, if it exists.Parameters: name (str) – Name of the executable to find Returns: Full path to the executable or NoneReturn type: strorNone
-
safe.util.prompt_bool(prompt, default=False)[source]¶ Prompt user for a yes or no answer and return the result as a boolean.
Parameters: Returns: Boolean indicating user’s choice
Return type:
-
safe.util.temporary_directory(*args, **kwds)[source]¶ Context manager that creates a temporary directory for use in the body.
Example:
with temporary_directory() as tmp: # do stuff with tmp
The temporary directory permissions are set to 0700 before handing control over to the body.
-
class
safe.util.Subprocess(<subprocess.Popen arguments>)[source]¶ Bases:
subprocess.PopenSubclass whose
communicate()method turns bytes into strings.