Utilities¶
This module contains a variety of helper functions that implement common tasks, like command-line output and date formatting. These should generally be used to help make Pavilion consistent across its code and plugins.
Table of Contents
Test and Suite Directories¶
-
pavilion.utils.
make_id_path
(base_path, id_)¶ Create the full path to an id directory given its base path and the id.
Parameters: - base_path (Path) – The path to where id directories are stored.
- id (int) – The id number
Return type: Path
File Handling¶
-
pavilion.utils.
flat_walk
(path, *args, **kwargs)¶ - Perform an os.walk on path, but return a flattened list of every file
- and directory found.
Parameters: - path (Path) – The path to walk with os.walk.
- args – Any additional positional args for os.walk.
- kwargs – Any additional kwargs for os.walk.
Returns: A list of all directories and files in or under the given path.
Rtype list[Path]:
-
pavilion.utils.
get_mime_type
(path)¶ Use the filemagic command to get the mime type of a file. Returned as a tuple of category and subtype.
Parameters: path (Path) – The path to the file to examine. Return type: (str, str) Returns: category, subtype
OS Operations¶
-
pavilion.utils.
get_login
()¶ Get the current user’s login, either through os.getlogin or the environment, or the id command.