paths#
Add docs here.
Module documentation#
General utilities for managing file paths.
- class easely.paths.WorkspaceLayout(*values)[source]#
Small Enum class with the basic folder structure within each conference root folder.
- ATTACHMENTS = 'indico_attachments'#
- QRCODES = 'qrcodes'#
- POSTERS = 'posters'#
- HEADSHOTS = 'presenters'#
- RASTERED_POSTERS = 'posters_raster'#
- CROPPED_HEADSHOTS = 'presenters_crop'#
- easely.paths.contribution_file_name(friendly_id: int, suffix: str) str[source]#
Return the standardized file name for a contribution file, given its
friendly_idon indico and the expected suffix.Arguments#
- friendly_idint
The contribution friendly id on indico
- suffixstr
The target file suffix, including the dot, e.g., “.pdf” or “.jpg
Returns#
- str
The standardized file name for the contribution file, e.g., “0001.pdf”.
- easely.paths.friendly_id(file_path: Path) int[source]#
Return the friendly id corresponding to a given contribution file path, by parsing the file name.
Return None if the file name does not start with an integer friendly id.
Arguments#
- file_pathpathlib.Path
The path to the contribution file, from which we want to extract the friendly id.
Returns#
- int or None
The friendly id corresponding to the given contribution file path, or None if the file name does not start with an integer friendly id.
- easely.paths.filter_dir(input_dir: Path, friendly_ids: List[int] = None) List[Path][source]#
Filter the list of files in a given input directory, by keeping only those whose contribution id is in the given list of friendly ids.
Note that, while when we know the file type this can be done programmatically, in the general case you really need to filter the list from the complete one.
Arguments#
- input_dirpathlib.Path
The path to the input directory, from which we want to filter the files.
- friendly_idslist of int, optional
The list of contribution friendly ids to keep (None to keep all files).
Returns#
- list of pathlib.Path
The list of file paths in the input directory.
- easely.paths.sanitize_file_path(path: str | Path, suffix: str = None, check_exists: bool = False) Path[source]#
Sanitize a file path, i.e, convert it to a pathlib.Path object, optionally ensuring it comes with the correct suffix and/or exists.
Note this can be used for both input and output file paths, depending on the values of the suffix and check_exists parameters.
Arguments#
- pathPathLike
The file path (either a string or a pathlib.Path object).
- suffixstr, optional
The expected file suffix (None to disengage the check).
- check_existsbool
Whether to check if the file exists.
Returns#
- pathlib.Path
The sanitized file path, as a pathlib.Path object.
- easely.paths.sanitize_folder_path(path: str | Path, create: bool = False) Path[source]#
Sanitize a folder path, i.e, convert it to a pathlib.Path object and, optionally, create it if it does not exist.
Arguments#
- pathPathLike
The path to the output folder.
- createbool
Whether to create the folder if it does not exist.
Returns#
- pathlib.Path
The path to the output folder, as a pathlib.Path object.