diff options
author | Lipu Fei <lipu.fei815@gmail.com> | 2018-07-11 12:14:57 +0300 |
---|---|---|
committer | Lipu Fei <lipu.fei815@gmail.com> | 2018-07-11 12:14:57 +0300 |
commit | af02dc2758b8eec1f3c3ccc2b96c5cb9bdc5276a (patch) | |
tree | c8c1eacfbd2e34a67807aacf6873e3d270723993 /plugins | |
parent | 76417b7fb2069cca39f774c7fbf47c7120afa480 (diff) |
Only use setMetaDataEntry()
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/3MFReader/ThreeMFWorkspaceReader.py | 2 | ||||
-rw-r--r-- | plugins/CuraProfileReader/CuraProfileReader.py | 2 | ||||
-rw-r--r-- | plugins/GCodeWriter/GCodeWriter.py | 10 | ||||
-rw-r--r-- | plugins/LegacyProfileReader/LegacyProfileReader.py | 4 | ||||
-rwxr-xr-x | plugins/MachineSettingsAction/MachineSettingsAction.py | 5 | ||||
-rw-r--r-- | plugins/PostProcessingPlugin/PostProcessingPlugin.py | 2 | ||||
-rw-r--r-- | plugins/PostProcessingPlugin/Script.py | 2 | ||||
-rw-r--r-- | plugins/UM3NetworkPrinting/DiscoverUM3Action.py | 6 | ||||
-rw-r--r-- | plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py | 10 | ||||
-rw-r--r-- | plugins/UltimakerMachineActions/UM2UpgradeSelection.py | 5 | ||||
-rw-r--r-- | plugins/XmlMaterialProfile/XmlMaterialProfile.py | 3 |
11 files changed, 18 insertions, 33 deletions
diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index 008bf24cda..f72029524e 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -963,7 +963,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader): if not extruder_info: continue if "enabled" not in extruder_stack.getMetaData(): - extruder_stack.addMetaDataEntry("enabled", "True") + extruder_stack.setMetaDataEntry("enabled", "True") extruder_stack.setMetaDataEntry("enabled", str(extruder_info.enabled)) def _updateActiveMachine(self, global_stack): diff --git a/plugins/CuraProfileReader/CuraProfileReader.py b/plugins/CuraProfileReader/CuraProfileReader.py index d7370326e4..5957b2cecf 100644 --- a/plugins/CuraProfileReader/CuraProfileReader.py +++ b/plugins/CuraProfileReader/CuraProfileReader.py @@ -75,7 +75,7 @@ class CuraProfileReader(ProfileReader): def _loadProfile(self, serialized, profile_id): # Create an empty profile. profile = InstanceContainer(profile_id) - profile.addMetaDataEntry("type", "quality_changes") + profile.setMetaDataEntry("type", "quality_changes") try: profile.deserialize(serialized) except ContainerFormatError as e: diff --git a/plugins/GCodeWriter/GCodeWriter.py b/plugins/GCodeWriter/GCodeWriter.py index d334c66dbe..aea0698d19 100644 --- a/plugins/GCodeWriter/GCodeWriter.py +++ b/plugins/GCodeWriter/GCodeWriter.py @@ -127,11 +127,11 @@ class GCodeWriter(MeshWriter): flat_global_container = self._createFlattenedContainerInstance(stack.userChanges, container_with_profile) # If the quality changes is not set, we need to set type manually if flat_global_container.getMetaDataEntry("type", None) is None: - flat_global_container.addMetaDataEntry("type", "quality_changes") + flat_global_container.setMetaDataEntry("type", "quality_changes") # Ensure that quality_type is set. (Can happen if we have empty quality changes). if flat_global_container.getMetaDataEntry("quality_type", None) is None: - flat_global_container.addMetaDataEntry("quality_type", stack.quality.getMetaDataEntry("quality_type", "normal")) + flat_global_container.setMetaDataEntry("quality_type", stack.quality.getMetaDataEntry("quality_type", "normal")) # Get the machine definition ID for quality profiles machine_definition_id_for_quality = getMachineDefinitionIDForQualitySearch(stack.definition) @@ -151,15 +151,15 @@ class GCodeWriter(MeshWriter): flat_extruder_quality = self._createFlattenedContainerInstance(extruder.userChanges, extruder_quality) # If the quality changes is not set, we need to set type manually if flat_extruder_quality.getMetaDataEntry("type", None) is None: - flat_extruder_quality.addMetaDataEntry("type", "quality_changes") + flat_extruder_quality.setMetaDataEntry("type", "quality_changes") # Ensure that extruder is set. (Can happen if we have empty quality changes). if flat_extruder_quality.getMetaDataEntry("position", None) is None: - flat_extruder_quality.addMetaDataEntry("position", extruder.getMetaDataEntry("position")) + flat_extruder_quality.setMetaDataEntry("position", extruder.getMetaDataEntry("position")) # Ensure that quality_type is set. (Can happen if we have empty quality changes). if flat_extruder_quality.getMetaDataEntry("quality_type", None) is None: - flat_extruder_quality.addMetaDataEntry("quality_type", extruder.quality.getMetaDataEntry("quality_type", "normal")) + flat_extruder_quality.setMetaDataEntry("quality_type", extruder.quality.getMetaDataEntry("quality_type", "normal")) # Change the default definition flat_extruder_quality.setMetaDataEntry("definition", machine_definition_id_for_quality) diff --git a/plugins/LegacyProfileReader/LegacyProfileReader.py b/plugins/LegacyProfileReader/LegacyProfileReader.py index 40a843e6c4..93c15ca8e0 100644 --- a/plugins/LegacyProfileReader/LegacyProfileReader.py +++ b/plugins/LegacyProfileReader/LegacyProfileReader.py @@ -145,9 +145,9 @@ class LegacyProfileReader(ProfileReader): if len(profile.getAllKeys()) == 0: Logger.log("i", "A legacy profile was imported but everything evaluates to the defaults, creating an empty profile.") - profile.addMetaDataEntry("type", "profile") + profile.setMetaDataEntry("type", "profile") # don't know what quality_type it is based on, so use "normal" by default - profile.addMetaDataEntry("quality_type", "normal") + profile.setMetaDataEntry("quality_type", "normal") profile.setName(profile_id) profile.setDirty(True) diff --git a/plugins/MachineSettingsAction/MachineSettingsAction.py b/plugins/MachineSettingsAction/MachineSettingsAction.py index acfec7938d..afd7aac86d 100755 --- a/plugins/MachineSettingsAction/MachineSettingsAction.py +++ b/plugins/MachineSettingsAction/MachineSettingsAction.py @@ -135,10 +135,7 @@ class MachineSettingsAction(MachineAction): material_node = None if has_materials: - if "has_materials" in self._global_container_stack.getMetaData(): - self._global_container_stack.setMetaDataEntry("has_materials", True) - else: - self._global_container_stack.addMetaDataEntry("has_materials", True) + self._global_container_stack.setMetaDataEntry("has_materials", True) else: # The metadata entry is stored in an ini, and ini files are parsed as strings only. # Because any non-empty string evaluates to a boolean True, we have to remove the entry to make it False. diff --git a/plugins/PostProcessingPlugin/PostProcessingPlugin.py b/plugins/PostProcessingPlugin/PostProcessingPlugin.py index 1bbe4bb66c..da971a8e61 100644 --- a/plugins/PostProcessingPlugin/PostProcessingPlugin.py +++ b/plugins/PostProcessingPlugin/PostProcessingPlugin.py @@ -248,7 +248,7 @@ class PostProcessingPlugin(QObject, Extension): global_stack = Application.getInstance().getGlobalContainerStack() if "post_processing_scripts" not in global_stack.getMetaData(): - global_stack.addMetaDataEntry("post_processing_scripts", "") + global_stack.setMetaDataEntry("post_processing_scripts", "") Application.getInstance().getGlobalContainerStack().setMetaDataEntry("post_processing_scripts", script_list_strs) ## Creates the view used by show popup. The view is saved because of the fairly aggressive garbage collection. diff --git a/plugins/PostProcessingPlugin/Script.py b/plugins/PostProcessingPlugin/Script.py index cc839ca485..7e430a5c78 100644 --- a/plugins/PostProcessingPlugin/Script.py +++ b/plugins/PostProcessingPlugin/Script.py @@ -48,7 +48,7 @@ class Script: self._stack.addContainer(self._definition) self._instance = InstanceContainer(container_id="ScriptInstanceContainer") self._instance.setDefinition(self._definition.getId()) - self._instance.addMetaDataEntry("setting_version", self._definition.getMetaDataEntry("setting_version", default = 0)) + self._instance.setMetaDataEntry("setting_version", self._definition.getMetaDataEntry("setting_version", default = 0)) self._stack.addContainer(self._instance) self._stack.propertyChanged.connect(self._onPropertyChanged) diff --git a/plugins/UM3NetworkPrinting/DiscoverUM3Action.py b/plugins/UM3NetworkPrinting/DiscoverUM3Action.py index b48a57e0a2..135bc06d3a 100644 --- a/plugins/UM3NetworkPrinting/DiscoverUM3Action.py +++ b/plugins/UM3NetworkPrinting/DiscoverUM3Action.py @@ -108,8 +108,8 @@ class DiscoverUM3Action(MachineAction): # Find all the places where there is the same group name and change it accordingly CuraApplication.getInstance().getMachineManager().replaceContainersMetadata(key = "connect_group_name", value = previous_connect_group_name, new_value = group_name) else: - global_container_stack.addMetaDataEntry("connect_group_name", group_name) - global_container_stack.addMetaDataEntry("hidden", False) + global_container_stack.setMetaDataEntry("connect_group_name", group_name) + global_container_stack.setMetaDataEntry("hidden", False) if self._network_plugin: # Ensure that the connection states are refreshed. @@ -130,7 +130,7 @@ class DiscoverUM3Action(MachineAction): global_container_stack.removeMetaDataEntry("network_authentication_key") CuraApplication.getInstance().getMachineManager().replaceContainersMetadata(key = "um_network_key", value = previous_network_key, new_value = key) else: - global_container_stack.addMetaDataEntry("um_network_key", key) + global_container_stack.setMetaDataEntry("um_network_key", key) if self._network_plugin: # Ensure that the connection states are refreshed. diff --git a/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py b/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py index 9b90f8542d..4c5d56e0da 100644 --- a/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/LegacyUM3OutputDevice.py @@ -458,15 +458,9 @@ class LegacyUM3OutputDevice(NetworkedPrinterOutputDevice): def _saveAuthentication(self): global_container_stack = CuraApplication.getInstance().getGlobalContainerStack() if global_container_stack: - if "network_authentication_key" in global_container_stack.getMetaData(): - global_container_stack.setMetaDataEntry("network_authentication_key", self._authentication_key) - else: - global_container_stack.addMetaDataEntry("network_authentication_key", self._authentication_key) + global_container_stack.setMetaDataEntry("network_authentication_key", self._authentication_key) - if "network_authentication_id" in global_container_stack.getMetaData(): - global_container_stack.setMetaDataEntry("network_authentication_id", self._authentication_id) - else: - global_container_stack.addMetaDataEntry("network_authentication_id", self._authentication_id) + global_container_stack.setMetaDataEntry("network_authentication_id", self._authentication_id) # Force save so we are sure the data is not lost. CuraApplication.getInstance().saveStack(global_container_stack) diff --git a/plugins/UltimakerMachineActions/UM2UpgradeSelection.py b/plugins/UltimakerMachineActions/UM2UpgradeSelection.py index e21256f6bd..6ff3f0b629 100644 --- a/plugins/UltimakerMachineActions/UM2UpgradeSelection.py +++ b/plugins/UltimakerMachineActions/UM2UpgradeSelection.py @@ -47,10 +47,7 @@ class UM2UpgradeSelection(MachineAction): variant_container = global_container_stack.extruders["0"].variant if has_variants: - if "has_variants" in global_container_stack.getMetaData(): - global_container_stack.setMetaDataEntry("has_variants", True) - else: - global_container_stack.addMetaDataEntry("has_variants", True) + global_container_stack.setMetaDataEntry("has_variants", True) # Set the variant container to a sane default empty_container = ContainerRegistry.getInstance().getEmptyInstanceContainer() diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index ca6271391e..eac6646197 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -63,7 +63,6 @@ class XmlMaterialProfile(InstanceContainer): # Prevent recursion if not apply_to_all: - super().addMetaDataEntry(key, value) super().setMetaDataEntry(key, value) return @@ -75,14 +74,12 @@ class XmlMaterialProfile(InstanceContainer): # Update the root material container root_material_container = material_group.root_material_node.getContainer() if root_material_container is not None: - root_material_container.addMetaDataEntry(key, value) root_material_container.setMetaDataEntry(key, value, apply_to_all = False) # Update all containers derived from it for node in material_group.derived_material_node_list: container = node.getContainer() if container is not None: - container.addMetaDataEntry(key, value) container.setMetaDataEntry(key, value, apply_to_all = False) ## Overridden from InstanceContainer, similar to setMetaDataEntry. |