mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 00:07:51 -06:00
Add typing for all version upgrade plug-ins
Hopefully we'll take this typing along when we next copy-paste the stuffs. Contributes to issue CURA-5936.
This commit is contained in:
parent
fe66d15b9e
commit
ae2b312472
21 changed files with 200 additions and 150 deletions
|
@ -1,14 +1,15 @@
|
|||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
# 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 typing import Dict, List, Set, Tuple
|
||||
|
||||
from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this.
|
||||
|
||||
|
||||
# a list of all legacy "Not Supported" quality profiles
|
||||
_OLD_NOT_SUPPORTED_PROFILES = [
|
||||
_OLD_NOT_SUPPORTED_PROFILES = {
|
||||
"um2p_pp_0.25_normal",
|
||||
"um2p_tpu_0.8_normal",
|
||||
"um3_bb0.4_ABS_Fast_Print",
|
||||
|
@ -42,7 +43,7 @@ _OLD_NOT_SUPPORTED_PROFILES = [
|
|||
"um3_bb0.8_PP_Superdraft_Print",
|
||||
"um3_bb0.8_TPU_Fast_print",
|
||||
"um3_bb0.8_TPU_Superdraft_Print",
|
||||
]
|
||||
} # type: Set[str]
|
||||
|
||||
|
||||
# Some containers have their specific empty containers, those need to be set correctly.
|
||||
|
@ -51,13 +52,13 @@ _EMPTY_CONTAINER_DICT = {
|
|||
"2": "empty_quality",
|
||||
"3": "empty_material",
|
||||
"4": "empty_variant",
|
||||
}
|
||||
} # type: Dict[str, str]
|
||||
|
||||
|
||||
# Renamed definition files
|
||||
_RENAMED_DEFINITION_DICT = {
|
||||
"jellybox": "imade3d_jellybox",
|
||||
}
|
||||
} # type: Dict[str, str]
|
||||
|
||||
|
||||
class VersionUpgrade30to31(VersionUpgrade):
|
||||
|
@ -72,7 +73,7 @@ class VersionUpgrade30to31(VersionUpgrade):
|
|||
# \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):
|
||||
def getCfgVersion(self, serialised: str) -> int:
|
||||
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.
|
||||
|
@ -83,7 +84,7 @@ class VersionUpgrade30to31(VersionUpgrade):
|
|||
#
|
||||
# \param serialised The serialised form of a preferences file.
|
||||
# \param filename The name of the file to upgrade.
|
||||
def upgradePreferences(self, serialised, filename):
|
||||
def upgradePreferences(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
|
||||
parser = configparser.ConfigParser(interpolation = None)
|
||||
parser.read_string(serialised)
|
||||
|
||||
|
@ -104,7 +105,7 @@ class VersionUpgrade30to31(VersionUpgrade):
|
|||
#
|
||||
# \param serialised The serialised form of the container file.
|
||||
# \param filename The name of the file to upgrade.
|
||||
def upgradeInstanceContainer(self, serialised, filename):
|
||||
def upgradeInstanceContainer(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
|
||||
parser = configparser.ConfigParser(interpolation = None)
|
||||
parser.read_string(serialised)
|
||||
|
||||
|
@ -129,7 +130,7 @@ class VersionUpgrade30to31(VersionUpgrade):
|
|||
#
|
||||
# \param serialised The serialised form of a container stack.
|
||||
# \param filename The name of the file to upgrade.
|
||||
def upgradeStack(self, serialised, filename):
|
||||
def upgradeStack(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
|
||||
parser = configparser.ConfigParser(interpolation = None)
|
||||
parser.read_string(serialised)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue