construct_filepath¶
- namefiles.construct_filepath(filename_template: Optional[str] = None, filename_validator: Optional[namefiles.JsonschemaValidator] = None, root_path: Optional[str] = None, **filename_parts) pathlib.Path ¶
Constructs a filepath using a file naming convention.
- Parameters
filename_template – A template providing a
format
method to be called with the fileparts.filename_validator – The validator to validate the filename parts with its file naming convention.
root_path – The file’s root path.
**filename_parts – File name parts as keywords to be used for the filename construction.
- Returns
Path
Examples
>>> from namefiles import construct_filepath, FILENAME_VALIDATOR >>> sample_pathlib_path = construct_filepath( ... root_path="/a/path", identifier="file", sub_id="NAME" ... ) >>> str(sample_pathlib_path) '/a/path/file#NAME'