gemseo.utils.file_path_manager module#
Services for handling file paths.
- class FileDefinition(name, extension)[source]#
Bases:
NamedTuple
The definition of a file name.
Create new instance of FileDefinition(name, extension)
- class FilePathManager(file_type, default_name='', default_directory='', default_extension='')[source]#
Bases:
object
A manager of file paths for a given type of file and with default settings.
- Parameters:
file_type (FileType) -- The type of file, defined by its default file name and format; select a file type by iterating over
FileType
.default_name (str) --
The default file name. If empty, use the default file name related to the given type of file.
By default it is set to "".
default_directory (Path | str) --
The default directory path. If empty, use the current working directory.
By default it is set to "".
default_extension (str) --
The default extension. If empty, use the default extension related to the given type of file.
By default it is set to "".
- class FileType(value)[source]#
Bases:
LowercaseStrEnum
The type of file, defined by its default name and format.
- FIGURE = 'figure'#
- SCHEMA = 'schema'#
- TEXT = 'document'#
- WEBPAGE = 'page'#
- classmethod add_suffix(file_path, suffix)[source]#
Add a suffix to an existing file path between the filename and the extension.
E.g. directory/filename_suffix.pdf.
- create_file_path(file_path='', directory_path='', file_name='', file_extension='')[source]#
Make a file path from a directory path, a file name and a file extension.
- Parameters:
file_path (str | Path) --
The path of the file to be returned. If empty, create a file path from
directory_path
,file_name
andfile_extension
.By default it is set to "".
directory_path (str | Path) --
The path of the directory. If empty, use the default directory path.
By default it is set to "".
file_name (str) --
The file name to be used. If empty, use the default file name.
By default it is set to "".
file_extension (str) --
A file extension, e.g. 'png', 'pdf', 'svg', ... If empty, use the default file extension.
By default it is set to "".
- Returns:
The file path.
- Return type:
Path