spinetoolbox.project¶
Spine Toolbox project class.
| authors: |
|
|---|---|
| date: | 10.1.2018 |
Module Contents¶
Classes¶
SpineToolboxProject |
Class for Spine Toolbox projects. |
-
class
spinetoolbox.project.SpineToolboxProject(toolbox, name, description, p_dir, project_item_model, settings, embedded_julia_console, embedded_python_console, logger)[source]¶ Bases:
spinetoolbox.metaobject.MetaObjectClass for Spine Toolbox projects.
Parameters: - toolbox (ToolboxUI) – toolbox of this project
- name (str) – Project name
- description (str) – Project description
- p_dir (str) – Project directory
- project_item_model (ProjectItemModel) – project item tree model
- settings (QSettings) – Toolbox settings
- embedded_julia_console (JuliaConsoleWidget) – a Julia console widget for execution in the embedded console
- embedded_python_console (PythonConsoleWidget) – a Python console widget for execution in the embedded console
- logger (LoggerInterface) – a logger instance
-
_create_project_structure(self, directory)[source]¶ Makes the given directory a Spine Toolbox project directory. Creates directories and files that are common to all projects.
Parameters: directory (str) – Abs. path to a directory that should be made into a project directory Returns: True if project structure was created successfully, False otherwise Return type: bool
-
set_description(self, description)[source]¶ Set object description.
Parameters: description (str) – Object description
-
save(self, spec_paths)[source]¶ Collects project information and objects into a dictionary and writes it to a JSON file.
Parameters: spec_paths (list) – List of absolute paths to specification files Returns: True or False depending on success Return type: bool
-
load(self, items_dict)[source]¶ Populates project item model with items loaded from project file.
Parameters: items_dict (dict) – Dictionary containing all project items in JSON format Returns: True if successful, False otherwise Return type: bool
-
add_project_items(self, item_type, *items, set_selected=False, verbosity=True)[source]¶ Pushes an AddProjectItemsCommand to the toolbox undo stack.
-
make_project_tree_items(self, item_type, items)[source]¶ Creates and returns a dictionary mapping category indexes to a list of corresponding LeafProjectTreeItem instances.
Parameters: - item_type (str) – item type
- items (list) – one or more dicts of items to add
Returns: dict(QModelIndex, list(LeafProjectTreeItem))
-
do_add_project_tree_items(self, category_ind, *project_tree_items, set_selected=False, verbosity=True)[source]¶ Adds LeafProjectTreeItem instances to project.
Parameters: - category_ind (QModelIndex) – The category index
- project_tree_items (LeafProjectTreeItem) – one or more LeafProjectTreeItem instances to add
- set_selected (bool) – Whether to set item selected after the item has been added to project
- verbosity (bool) – If True, prints message
-
set_item_selected(self, item)[source]¶ Selects the given item.
Parameters: item (LeafProjectTreeItem) –
-
make_and_add_project_items(self, item_type, items, set_selected=False, verbosity=True)[source]¶ Adds items to project at loading.
Parameters: - item_type (str) – Item type e.g. “Tool”
- items (list) – one or more dict of items to add
- set_selected (bool) – Whether to set item selected after the item has been added to project
- verbosity (bool) – If True, prints message
-
remove_item(self, name, check_dialog=False)[source]¶ Pushes a RemoveProjectItemCommand to the toolbox undo stack.
Parameters: - name (str) – Item’s name
- check_dialog (bool) – If True, shows ‘Are you sure?’ message box
-
do_remove_item(self, name)[source]¶ Removes item from project given its name. This method is used when closing the existing project for opening a new one.
Parameters: name (str) – Item’s name
-
_remove_item(self, category_ind, item, delete_data=False)[source]¶ Removes LeafProjectTreeItem from project.
Parameters: - category_ind (QModelIndex) – The category index
- item (LeafProjectTreeItem) – the item to remove
- delete_data (bool) – If set to True, deletes the directories and data associated with the item
-
execute_dags(self, dags, execution_permits)[source]¶ Executes given dags.
Parameters: - dags (Sequence(DiGraph)) –
- execution_permits (Sequence(dict)) –
-
execute_dag(self, dag, execution_permits, dag_identifier)[source]¶ Executes given dag.
Parameters: - dag (DiGraph) – Executed DAG
- execution_permits (dict) – Dictionary, where keys are node names in dag and value is a boolean
- dag_identifier (str) – Identifier number for printing purposes
-
notify_changes_in_containing_dag(self, item)[source]¶ Notifies items in dag containing the given item that the dag has changed.