Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLipu Fei <lipu.fei815@gmail.com>2018-04-04 12:49:00 +0300
committerLipu Fei <lipu.fei815@gmail.com>2018-04-05 16:14:15 +0300
commit19bc2b78f49e8738117aec28f69681069c96ab03 (patch)
tree51b4f90a61af7a150e15d357195ac73a6ea1fb65 /plugins/VersionUpgrade/VersionUpgrade33to34
parentc3fe53123b2b28c36f3fa60627919916dfc758fa (diff)
Add Version upgrade 3.3 to 3.4
Need to distinguish between quality and quality_changes in the cura directory, so we need to move all custom quality profiles into the quality_changes directory.
Diffstat (limited to 'plugins/VersionUpgrade/VersionUpgrade33to34')
-rw-r--r--plugins/VersionUpgrade/VersionUpgrade33to34/VersionUpgrade33to34.py43
-rw-r--r--plugins/VersionUpgrade/VersionUpgrade33to34/__init__.py35
-rw-r--r--plugins/VersionUpgrade/VersionUpgrade33to34/plugin.json8
3 files changed, 86 insertions, 0 deletions
diff --git a/plugins/VersionUpgrade/VersionUpgrade33to34/VersionUpgrade33to34.py b/plugins/VersionUpgrade/VersionUpgrade33to34/VersionUpgrade33to34.py
new file mode 100644
index 0000000000..4e7b09564a
--- /dev/null
+++ b/plugins/VersionUpgrade/VersionUpgrade33to34/VersionUpgrade33to34.py
@@ -0,0 +1,43 @@
+# Copyright (c) 2018 Ultimaker B.V.
+# Cura is released under the terms of the LGPLv3 or higher.
+
+import configparser #To parse preference files.
+import io #To serialise the preference files afterwards.
+
+from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this.
+
+
+## Upgrades configurations from the state they were in at version 3.2 to the
+# state they should be in at version 3.3.
+class VersionUpgrade33to34(VersionUpgrade):
+
+ ## Gets the version number from a CFG file in Uranium's 3.2 format.
+ #
+ # Since the format may change, this is implemented for the 3.2 format only
+ # and needs to be included in the version upgrade system rather than
+ # globally in Uranium.
+ #
+ # \param serialised The serialised form of a CFG file.
+ # \return The version number stored in the CFG file.
+ # \raises ValueError The format of the version number in the file is
+ # incorrect.
+ # \raises KeyError The format of the file is incorrect.
+ def getCfgVersion(self, serialised):
+ parser = configparser.ConfigParser(interpolation = None)
+ parser.read_string(serialised)
+ format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
+ setting_version = int(parser.get("metadata", "setting_version", fallback = 0))
+ return format_version * 1000000 + setting_version
+
+ ## Upgrades instance containers to have the new version
+ # number.
+ def upgradeInstanceContainer(self, serialized, filename):
+ parser = configparser.ConfigParser(interpolation = None)
+ parser.read_string(serialized)
+
+ # Update version number.
+ parser["general"]["version"] = "4"
+
+ result = io.StringIO()
+ parser.write(result)
+ return [filename], [result.getvalue()]
diff --git a/plugins/VersionUpgrade/VersionUpgrade33to34/__init__.py b/plugins/VersionUpgrade/VersionUpgrade33to34/__init__.py
new file mode 100644
index 0000000000..c36247353f
--- /dev/null
+++ b/plugins/VersionUpgrade/VersionUpgrade33to34/__init__.py
@@ -0,0 +1,35 @@
+# Copyright (c) 2018 Ultimaker B.V.
+# Cura is released under the terms of the LGPLv3 or higher.
+
+from . import VersionUpgrade33to34
+
+upgrade = VersionUpgrade33to34.VersionUpgrade33to34()
+
+
+def getMetaData():
+ return {
+ "version_upgrade": {
+ # From To Upgrade function
+ ("definition_changes", 3000004): ("definition_changes", 4000004, upgrade.upgradeInstanceContainer),
+ ("quality_changes", 3000004): ("quality_changes", 4000004, upgrade.upgradeInstanceContainer),
+ ("user", 3000004): ("user", 4000004, upgrade.upgradeInstanceContainer),
+ },
+ "sources": {
+ "definition_changes": {
+ "get_version": upgrade.getCfgVersion,
+ "location": {"./definition_changes"}
+ },
+ "quality_changes": {
+ "get_version": upgrade.getCfgVersion,
+ "location": {"./quality"}
+ },
+ "user": {
+ "get_version": upgrade.getCfgVersion,
+ "location": {"./user"}
+ }
+ }
+ }
+
+
+def register(app):
+ return { "version_upgrade": upgrade }
diff --git a/plugins/VersionUpgrade/VersionUpgrade33to34/plugin.json b/plugins/VersionUpgrade/VersionUpgrade33to34/plugin.json
new file mode 100644
index 0000000000..164b79d504
--- /dev/null
+++ b/plugins/VersionUpgrade/VersionUpgrade33to34/plugin.json
@@ -0,0 +1,8 @@
+ {
+ "name": "Version Upgrade 3.3 to 3.4",
+ "author": "Ultimaker B.V.",
+ "version": "1.0.0",
+ "description": "Upgrades configurations from Cura 3.3 to Cura 3.4.",
+ "api": 4,
+ "i18n-catalog": "cura"
+}