spinetoolbox.project_upgrader
¶
Contains ProjectUpgrader class used in upgrading and converting projects and project dicts from earlier versions to the latest version.
- authors
Savolainen (VTT)
- date
8.11.2019
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(self, 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(self, 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(self, 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
- Returns
Version 6 project dictionary
- Return type
dict
- get_project_directory(self)[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_v1(self, 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_6(self, p, v)[source]¶
Checks that the given project JSON dictionary contains a valid version 2 to 6 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 project, False if it is not
- Return type
bool