mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Use VersionUpgradeManager to update the imported quality
CURA-6659
This commit is contained in:
parent
483e343b38
commit
6bb3e33c9e
1 changed files with 17 additions and 12 deletions
|
@ -67,9 +67,10 @@ class CuraProfileReader(ProfileReader):
|
|||
return []
|
||||
|
||||
version = int(parser["general"]["version"])
|
||||
setting_version = int(parser["metadata"].get("setting_version", 0))
|
||||
if InstanceContainer.Version != version:
|
||||
name = parser["general"]["name"]
|
||||
return self._upgradeProfileVersion(serialized, name, version)
|
||||
return self._upgradeProfileVersion(serialized, name, version, setting_version)
|
||||
else:
|
||||
return [(serialized, profile_id)]
|
||||
|
||||
|
@ -98,19 +99,23 @@ class CuraProfileReader(ProfileReader):
|
|||
# \param profile_id The name of the profile.
|
||||
# \param source_version The profile version of 'serialized'.
|
||||
# \return List of serialized profile strings and matching profile names.
|
||||
def _upgradeProfileVersion(self, serialized: str, profile_id: str, source_version: int) -> List[Tuple[str, str]]:
|
||||
converter_plugins = PluginRegistry.getInstance().getAllMetaData(filter = {"version_upgrade": {} }, active_only = True)
|
||||
def _upgradeProfileVersion(self, serialized: str, profile_id: str, main_version: int, setting_version: int) -> List[Tuple[str, str]]:
|
||||
source_version = main_version * 1000000 + setting_version
|
||||
|
||||
source_format = ("profile", source_version)
|
||||
profile_convert_funcs = [plugin["version_upgrade"][source_format][2] for plugin in converter_plugins
|
||||
if source_format in plugin["version_upgrade"] and plugin["version_upgrade"][source_format][1] == InstanceContainer.Version]
|
||||
from UM.VersionUpgradeManager import VersionUpgradeManager
|
||||
results = VersionUpgradeManager.getInstance().updateFilesData("quality_changes", source_version, [serialized], [profile_id])
|
||||
serialized = results.files_data[0]
|
||||
|
||||
if not profile_convert_funcs:
|
||||
Logger.log("w", "Unable to find an upgrade path for the profile [%s]", profile_id)
|
||||
parser = configparser.ConfigParser(interpolation = None)
|
||||
parser.read_string(serialized)
|
||||
if "general" not in parser:
|
||||
Logger.log("w", "Missing required section 'general'.")
|
||||
return []
|
||||
if "version" not in parser["general"]:
|
||||
Logger.log("w", "Missing required 'version' property")
|
||||
return []
|
||||
|
||||
filenames, outputs = profile_convert_funcs[0](serialized, profile_id)
|
||||
if filenames is None and outputs is None:
|
||||
Logger.log("w", "The conversion failed to return any usable data for [%s]", profile_id)
|
||||
if int(parser["general"]["version"]) != InstanceContainer.Version:
|
||||
Logger.log("e", "Failed to upgrade profile [%s]", profile_id)
|
||||
return []
|
||||
return list(zip(outputs, filenames))
|
||||
return [(serialized, profile_id)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue