diff options
author | Ghostkeeper <rubend@tutanota.com> | 2018-11-14 15:56:46 +0300 |
---|---|---|
committer | Ghostkeeper <rubend@tutanota.com> | 2018-11-14 15:56:46 +0300 |
commit | 8ec7d6dba3b79dc88c9496185c6e49000740018a (patch) | |
tree | 8a889a9dc14919a5a18b3dfb244ed81d8738b694 /plugins/VersionUpgrade/VersionUpgrade22to24 | |
parent | b67d8d410343490b96357def995adb3a8f0d198f (diff) |
Fix type issues in old version upgrade plug-ins
The one actual change was this: To give a KeyError when stuff can't be found in a dictionary, rather than returning None there and then getting a TypeError later.
Contributes to issue CURA-5936.
Diffstat (limited to 'plugins/VersionUpgrade/VersionUpgrade22to24')
-rw-r--r-- | plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py b/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py index dac73683bb..ded892d137 100644 --- a/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py +++ b/plugins/VersionUpgrade/VersionUpgrade22to24/VersionUpgrade.py @@ -22,11 +22,11 @@ class VersionUpgrade22to24(VersionUpgrade): config.read_string(serialised) # Read the input string as config file.
if config.get("metadata", "type") == "definition_changes":
# This is not a container stack, don't upgrade it here
- return
+ return None
config.set("general", "version", "3")
- container_list = []
+ container_list = [] # type: List[str]
if config.has_section("containers"):
for index, container_id in config.items("containers"):
container_list.append(container_id)
@@ -37,14 +37,14 @@ class VersionUpgrade22to24(VersionUpgrade): user_variants = self.__getUserVariants()
name_path_dict = {}
for variant in user_variants:
- name_path_dict[variant.get("name")] = variant.get("path")
+ name_path_dict[variant["name"]] = variant["path"]
user_variant_names = set(container_list).intersection(name_path_dict.keys())
if len(user_variant_names):
# One of the user defined variants appears in the list of containers in the stack.
for variant_name in user_variant_names: # really there should just be one variant to convert.
- config_name = self.__convertVariant(name_path_dict.get(variant_name))
+ config_name = self.__convertVariant(name_path_dict[variant_name])
# Change the name of variant and insert empty_variant into the stack.
new_container_list = []
@@ -64,8 +64,8 @@ class VersionUpgrade22to24(VersionUpgrade): config.remove_option("general", "containers")
- for index in range(len(container_list)):
- config.set("containers", str(index), container_list[index])
+ for idx in range(len(container_list)):
+ config.set("containers", str(idx), container_list[idx])
output = io.StringIO()
config.write(output)
|