polychron.models.ProjectSelection
Module
ProjectSelection
A class containing a ProjectsDirectory object, and variables related to the currently selected project/model, and the next project/model to be slelected
__current_project_name
instance-attribute
__current_project_name: str | None = None
The currently selected project within the project directory.
__current_model_name
instance-attribute
__current_model_name: str | None = None
The currently selected model within the currently selected project for this projects directory.
__next_project_name
instance-attribute
__next_project_name: str | None = None
The name of the next project to be switched to, which may or may not exist
__next_model_name
instance-attribute
__next_model_name: str | None = None
The name of a next model to be switched to, which may or may not exist
__using_save_as
instance-attribute
__using_save_as: bool = False
Boolean indicating if the next model switch should copy the current model or not (if one is set).
__using_new_project_process
instance-attribute
__using_new_project_process: bool = False
Boolean indicating if the new/create project process is being used, of if project selection is being used.
This is to provide correct back button behaviour, without validating the user provided new project name does not already exist.
projects_directory
property
projects_directory: ProjectsDirectory
Get (a ref to) the projects directory object
No setter is provided.
Returns:
Type | Description |
---|---|
ProjectsDirectory
|
A reference to the ProjectsDirectory object |
current_project_name
property
writable
current_project_name: str | None
The name of the currently selected project, which may be None
current_model_name
property
writable
current_model_name: str | None
The name of the currently selected model, which may be None
current_project
property
current_project: Project | None
Get (a reference) to the currently selected Project object
current_model
property
current_model: Model | None
Get (a reference) to the currently selected model object
next_project_name
property
writable
next_project_name: str | None
Get the name of the next project to be selected/created, which may be None
next_model_name
property
writable
next_model_name: str | None
Get the name of the next model to be selected/created, which may be None
next_project
property
next_project: Project | None
Get (a reference) to the "next" Project object, if it already exists
next_model
property
next_model: Model | None
Get (a reference) to the "next" model object, if it already exists within the next project
using_save_as
property
writable
using_save_as: bool
Flag indicating if the next model should be copied from the current model or not.
using_new_project_process
property
writable
using_new_project_process: bool
Get if the next project was a user provided new name or not.
This does not mean the next project name is not already in use, but this is required to provide the correct back functionality during the project/model loading/creation process without validating new project names when provided.
__init__
__init__(projects_directory_path: Path)
Initialise an instance of the ProjectSelection class, using a projects directory from a specified path.
switch_to_next_project_model
switch_to_next_project_model(load_ok=True, create_ok=True) -> None
Switch to the next project & model, loading a project if it already exists, or creating it if not (unless load_only). potentially copying the current model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
load_ok
|
bool
|
If loading existing models is allowed |
True
|
create_ok
|
bool
|
If creating new models is allowed |
True
|
Raises:
Type | Description |
---|---|
RuntimeError
|
if the next_project_name or next_model_name are not specified or invalid; or if load_ok is False and the next_project_name and next_model_name specify an existing project; or if create_ok is False and the next_project_name and next_model_name specify a model which does not yet exist. |
ValueError
|
if both load_ok and create_ok are False, atleast one must be truthy. |
switch_to
switch_to(project_name: str, model_name: str, load_ok: bool = True, create_ok: bool = True) -> None
Switch to the specified project & model, loading a project if it already exists, or creating it if not (unless load_only). potentially copying the current model.
This is essentially an overload of switch_to_next_project_model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_name
|
str
|
Name of the next project |
required |
model_name
|
str
|
Name of the next model |
required |
load_ok
|
bool
|
If loading existing models is allowed |
True
|
create_ok
|
bool
|
If creating new models is allowed |
True
|
Raises:
Type | Description |
---|---|
RuntimeError
|
if the next_project_name or next_model_name are not specified or invalid; or if load_ok is False and the next_project_name and next_model_name specify an existing project; or if create_ok is False and the next_project_name and next_model_name specify a model which does not yet exist. |
ValueError
|
if both load_ok and create_ok are False, atleast one must be truthy. |