project.ProjectManager

Usage

Source

project.ProjectManager(username=None)

Attributes

Name Description
labrat_file Get the path to the .labrat config file.

labrat_file

Get the path to the .labrat config file.

labrat_file

Methods

Name Description
__init__() Initialize the project manager with a default username.
add_template() Add a new project template.
archive_project() Archive a project directory to a timestamped archive folder.
delete_project() Archive and delete a project directory.
list_project_files() List all files within the given project directory.
list_projects() List all projects stored in the .labrat file.
new_project() Create a new project and update its metadata in the .labrat file.
update_project() Update the last modified timestamp for an existing project.

__init__()

Initialize the project manager with a default username.

Usage

Source

__init__(username=None)
Parameters
username: str = None
The user’s name. Defaults to the value in .labrat or ‘default_user’.

add_template()

Add a new project template.

Usage

Source

add_template(name, url)
Parameters
name: str

The name of the template.

url: str
The repository URL of the template.
Raises
ValueError
If the template name already exists.

archive_project()

Archive a project directory to a timestamped archive folder.

Usage

Source

archive_project(project_path, archive_base_dir)
Parameters
project_path: str or Path

The path to the project directory.

archive_base_dir: str or Path
The base directory for storing archives.
Returns
str
Path to the created archive directory.

delete_project()

Archive and delete a project directory.

Usage

Source

delete_project(project_path, archive_base_dir)
Parameters
project_path: str or Path

The path to the project directory.

archive_base_dir: str or Path
The base directory for storing archives.
Raises
ValueError
If the project path does not exist or is not a directory.

list_project_files()

List all files within the given project directory.

Usage

Source

list_project_files(project_path)
Parameters
project_path: str
The path to the project.
Returns
list
A list of file paths within the project directory.

list_projects()

List all projects stored in the .labrat file.

Usage

Source

list_projects()
Returns
list
A list of project metadata dictionaries.

new_project()

Create a new project and update its metadata in the .labrat file.

Usage

Source

new_project(project_type, project_name, project_path, description)
Parameters
project_type: str

The type of project.

project_name: str

The name of your project.

project_path: str

The destination path of the project.

description: str
A description of the project.
Raises
ValueError
If the project type is not valid.

update_project()

Update the last modified timestamp for an existing project.

Usage

Source

update_project(project_path)
Parameters
project_path: str
The path to the project to update.