spinetoolbox.project

Spine Toolbox project class.

authors:
  1. Savolainen (VTT), E. Rinne (VTT)
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_finished[source]
dag_execution_about_to_start[source]

Emitted just before an engine runs. Provides a reference to the engine.

project_execution_about_to_start[source]

Emitted just before the entire project is executed.

settings[source]
connect_signals(self)[source]

Connect signals to slots.

_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
call_set_name(self, name)[source]
call_set_description(self, description)[source]
set_name(self, name)[source]

Changes project name.

Parameters:name (str) – New project name
set_description(self, description)[source]
static get_connections(links)[source]
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
add_to_dag(self, item_name)[source]

Add new node (project item) to the directed graph.

remove_all_items(self)[source]

Pushes a RemoveAllProjectItemsCommand to the toolbox undo stack.

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_next_dag(self)[source]

Executes next dag in the execution list.

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
execute_selected(self)[source]

Executes DAGs corresponding to all selected project items.

execute_project(self)[source]

Executes all dags in the project.

stop(self)[source]

Stops execution. Slot for the main window Stop tool button in the toolbar.

export_graphs(self)[source]

Exports all valid directed acyclic graphs in project to GraphML files.

notify_changes_in_dag(self, dag)[source]

Notifies the items in given dag that the dag has changed.

notify_changes_in_all_dags(self)[source]

Notifies all items of changes in all dags in the project.

notify_changes_in_containing_dag(self, item)[source]

Notifies items in dag containing the given item that the dag has changed.