polychron.models.ProjectsDirectory
Module
ProjectsDirectory
dataclass
MVP Model representing the projects directory
path
instance-attribute
path: Path
path to the projects directory this objet represents
projects
class-attribute
instance-attribute
projects: dict[str, Project] = field(default_factory=dict)
projects within the projects directory
lazy_load
lazy_load() -> None
Lazily load the projects for the current path
has_project
has_project(project_name: str) -> bool
Check if the specified project exists or not
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name
|
str
|
The name of the project. |
required |
Returns:
Type | Description |
---|---|
bool
|
If the project directory exists or not. |
get_project
get_project(project_name: str) -> Project | None
Fetch a project by it's name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name
|
str
|
The name of the project to fetch. |
required |
Returns:
Type | Description |
---|---|
Project | None
|
The project if it exists, else None. |
get_or_create_project
get_or_create_project(project_name: str) -> Project
Get or create a project within this projects directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name
|
str
|
The name of the project to be fetched or created |
required |
Returns:
Type | Description |
---|---|
Project
|
The existing or new project with the specified project name |