spinetoolbox.project
¶
Spine Toolbox project class.
authors: |
|
---|---|
date: | 10.1.2018 |
Module Contents¶
-
class
spinetoolbox.project.
SpineToolboxProject
(toolbox, name, description, p_dir, project_item_model, settings, logger)[source]¶ Bases:
spinetoolbox.metaobject.MetaObject
Class 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
- logger (LoggerInterface) – a logger instance
-
dag_execution_about_to_start
[source]¶ Emitted just before an engine runs. Provides a reference to the engine.
-
_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
-
save
(self, tool_spec_paths)[source]¶ Collects project information and objects into a dictionary and writes it to a JSON file.
Parameters: tool_spec_paths (list) – List of absolute paths to tool specification files Returns: True or False depending on success Return type: bool
-
load
(self, objects_dict)[source]¶ Populates project item model with items loaded from project file.
Parameters: objects_dict (dict) – Dictionary containing all project items in JSON format Returns: True if successful, False otherwise Return type: bool
-
load_tool_specification_from_file
(self, jsonfile)[source]¶ Returns a Tool specification from a definition file.
Parameters: jsonfile (str) – Path of the tool specification definition file Returns: ToolSpecification or None if reading the file failed
-
load_tool_specification_from_dict
(self, definition, path)[source]¶ Returns a Tool specification from a definition dictionary.
Parameters: - definition (dict) – Dictionary with the tool definition
- path (str) – Directory where main program file is located
Returns: ToolSpecification, NoneType
-
add_project_items
(self, category_name, *items, set_selected=False, verbosity=True)[source]¶ Pushes an AddProjectItemsCommand to the toolbox undo stack.
-
make_project_tree_items
(self, category_name, *items)[source]¶ Creates and returns list of LeafProjectTreeItem instances.
Parameters: - category_name (str) – The items’ category
- items (dict) – one or more dict of items to add
Returns: list(LeafProjectTreeItem)
-
_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) –
-
do_add_project_items
(self, category_name, *items, set_selected=False, verbosity=True)[source]¶ Adds items to project at loading.
Parameters: - category_name (str) – The items’ category
- items (dict) – 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)) –