Project Directory

class hal_py.ProjectDirectory

Represents a project directory.

static generate_random() hal_py.ProjectDirectory

Generates a random directory name in the current working directory.

Returns

The absolute path to the generated directory.

Return type

str

get_canonical_path(self: hal_py.ProjectDirectory) os.PathLike

Returns the canonical path to the project directory.

Returns

The absolute canonical path to the project directory. If no project path is given, an empty path is returned.

Return type

str

get_default_filename(self: hal_py.ProjectDirectory, extension: str = '') os.PathLike

Returns the default file name for the project directory, which is a file with the same name as the project directory plus an extension.

Parameters

extension (str) – Extension of the default file name. If empty, ‘.hal’ is assumed.

Returns

The absolute path to the default file.

Return type

str

get_filename(self: hal_py.ProjectDirectory, relative_filename: str) os.PathLike

Returns the absolute path to a file within the project directory.

Parameters

relative_filename (str) – The relative file name within the project directory.

Returns

The absolute path to the file.

Return type

str

get_relative_file_path(self: hal_py.ProjectDirectory, filename: str) os.PathLike

Returns the relative file path if the file is within the project directory.

Parameters

filename (str) – The absolute path to the file.

Returns

The relative file path if the file is within the project directory; otherwise, the original filename.

Return type

str

get_shadow_dir(self: hal_py.ProjectDirectory) os.PathLike

Returns the path to the autosave (shadow) directory.

Returns

The absolute path to the autosave directory.

Return type

str

get_shadow_filename(self: hal_py.ProjectDirectory, extension: str = '') os.PathLike

Returns the file name within the autosave (shadow) directory.

Parameters

extension (str) – Extension of the shadow file name. If empty, ‘.hal’ is assumed.

Returns

The absolute path to the shadow file.

Return type

str