spinetoolbox.project_upgrader
Contains ProjectUpgrader class used in upgrading and converting projects and project dicts from earlier versions to the latest version.
Module Contents
Classes
Class to upgrade/convert projects from earlier versions to the current version. |
Functions
|
Replaces '1d array' with 'array' for parameter type in Importer mappings. |
- class spinetoolbox.project_upgrader.ProjectUpgrader(toolbox)[source]
Class to upgrade/convert projects from earlier versions to the current version.
- Parameters:
toolbox (ToolboxUI) – App main window instance
- upgrade(project_dict, project_dir)[source]
Upgrades the project described in given project dictionary to the latest version.
- Parameters:
project_dict (dict) – Project configuration dictionary
project_dir (str) – Path to current project directory
- Returns:
Latest version of the project info dictionary
- Return type:
dict
- upgrade_to_latest(v, project_dict, project_dir)[source]
Upgrades the given project dictionary to the latest version.
- Parameters:
v (int) – Current version of the project dictionary
project_dict (dict) – Project dictionary (JSON) to be upgraded
project_dir (str) – Path to current project directory
- Returns:
Upgraded project dictionary
- Return type:
dict
- static upgrade_v1_to_v2(old, factories)[source]
Upgrades version 1 project dictionary to version 2.
- Changes:
objects -> items, tool_specifications -> specifications store project item dicts under [“items”][<project item name>] instead of using their categories as keys specifications must be a dict instead of a list Add specifications[“Tool”] that must be a dict Remove “short name” from all project items
- Parameters:
old (dict) – Version 1 project dictionary
factories (dict) – Mapping of item type to item factory
- Returns:
Version 2 project dictionary
- Return type:
dict
- upgrade_v2_to_v3(old, project_dir, factories)[source]
Upgrades version 2 project dictionary to version 3.
- Changes:
Move “specifications” from “project” -> “Tool” to just “project”
The “mappings” from importer items are used to build Importer specifications
- Parameters:
old (dict) – Version 2 project dictionary
project_dir (str) – Path to current project directory
factories (dict) – Mapping of item type to item factory
- Returns:
Version 3 project dictionary
- Return type:
dict
- static upgrade_v3_to_v4(old)[source]
Upgrades version 3 project dictionary to version 4.
- Changes:
Rename “Exporter” item type to “GdxExporter”
- Parameters:
old (dict) – Version 3 project dictionary
- Returns:
Version 4 project dictionary
- Return type:
dict
- static upgrade_v4_to_v5(old)[source]
Upgrades version 4 project dictionary to version 5.
- Changes:
Get rid of “Combiner” items.
- Parameters:
old (dict) – Version 4 project dictionary
- Returns:
Version 5 project dictionary
- Return type:
dict
- static upgrade_v5_to_v6(old, project_dir)[source]
Upgrades version 5 project dictionary to version 6.
- Changes:
Data store URL labels do not have ‘{’ and ‘}’ anymore
Importer stores resource labels instead of serialized paths in “file_selection”.
Gimlet’s “selections” is now called “file_selection”
Gimlet stores resource labels instead of serialized paths in “file_selection”.
Gimlet and Tool store command line arguments as serialized CmdLineArg objects, not serialized paths
- Parameters:
old (dict) – Version 5 project dictionary
project_dir (str) – Path to current project directory
- Returns:
Version 6 project dictionary
- Return type:
dict
- static upgrade_v6_to_v7(old)[source]
Upgrades version 6 project dictionary to version 7.
- Changes:
Introduces Mergers in between DS -> DS links.
- Parameters:
old (dict) – Version 6 project dictionary
- Returns:
Version 7 project dictionary
- Return type:
dict
- static upgrade_v7_to_v8(old)[source]
Upgrades version 7 project dictionary to version 8.
- Changes:
Move purge settings from items to their outgoing connections.
- Parameters:
old (dict) – Version 7 project dictionary
- Returns:
Version 8 project dictionary
- Return type:
dict
- static upgrade_v8_to_v9(old)[source]
Upgrades version 8 project dictionary to version 9.
- Changes:
Remove [“project”][“name”] key
- Parameters:
old (dict) – Version 8 project dictionary
- Returns:
Version 9 project dictionary
- Return type:
dict
- static upgrade_v9_to_v10(old)[source]
Upgrades version 9 project dictionary to version 10.
- Changes:
Remove connections from Gimlets and GDXExporters
Remove Gimlet items
- Parameters:
old (dict) – Version 9 project dictionary
- Returns:
Version 10 project dictionary
- Return type:
dict
- static upgrade_v10_to_v11(old)[source]
Upgrades version 10 project dictionary to version 11.
- Changes:
Add [“project”][“settings”] key
- Parameters:
old (dict) – Version 10 project dictionary
- Returns:
Version 11 project dictionary
- Return type:
dict
- static upgrade_v11_to_v12(old)[source]
Upgrades version 11 project dictionary to version 12.
- Changes:
1. Julia’s execution settings are now Tool Spec settings instead of global settings Execution settings are local user settings so this only updates the project version to make sure that these projects cannot be opened with an older Toolbox version.
- Parameters:
old (dict) – Version 11 project dictionary
- Returns:
Version 12 project dictionary
- Return type:
dict
- static upgrade_v12_to_v13(old)[source]
Upgrades version 12 project dictionary to version 13.
- Changes:
1. Connections now have enabled filter types field. Old projects should open just fine so this only updates the project version to make sure that these projects cannot be opened with an older Toolbox version.
- Parameters:
old (dict) – Version 12 project dictionary
- Returns:
Version 13 project dictionary
- Return type:
dict
- get_project_directory()[source]
Asks the user to select a new project directory. If the selected directory is already a Spine Toolbox project directory, asks if overwrite is ok. Used when opening a project from an old style project file (.proj).
- Returns:
Path to project directory or an empty string if operation is canceled.
- Return type:
str
- is_valid(v, p)[source]
Checks given project dict if it is valid for given version.
- Parameters:
v (int) – project version to validate against
p (dict) – project dictionary
- Returns:
True if project is valid, False otherwise
- Return type:
bool
- is_valid_v1(p)[source]
Checks that the given project JSON dictionary contains a valid version 1 Spine Toolbox project. Valid meaning, that it contains all required keys and values are of the correct type.
- Parameters:
p (dict) – Project information JSON
- Returns:
True if project is a valid version 1 project, False if it is not
- Return type:
bool
- is_valid_v2_to_v8(p, v)[source]
Checks that the given project JSON dictionary contains a valid version 2 to 8 Spine Toolbox project. Valid meaning, that it contains all required keys and values are of the correct type.
- Parameters:
p (dict) – Project information JSON
v (int) – Version
- Returns:
True if project is a valid version 2 to version 8 project, False if it is not
- Return type:
bool
- is_valid_v9_to_v10(p)[source]
Checks that the given project JSON dictionary contains a valid version 9 or 10 Spine Toolbox project. Valid meaning, that it contains all required keys and values are of the correct type.
- Parameters:
p (dict) – Project information JSON
- Returns:
True if project is a valid version 9 and 10 project, False otherwise
- Return type:
bool
- is_valid_v11_to_v12(p)[source]
Checks that the given project JSON dictionary contains a valid version 11 or 12 Spine Toolbox project. Valid meaning, that it contains all required keys and values are of the correct type.
- Parameters:
p (dict) – Project information JSON
- Returns:
True if project is a valid version 11 or 12 project, False otherwise
- Return type:
bool