Simplify for loop in _calculateInformation()

This commit is contained in:
Lipu Fei 2018-03-02 16:10:06 +01:00
parent 93190dde9b
commit 2135e30aad

View file

@ -212,14 +212,13 @@ class PrintInformation(QObject):
material_preference_values = json.loads(Preferences.getInstance().getValue("cura/material_settings")) material_preference_values = json.loads(Preferences.getInstance().getValue("cura/material_settings"))
extruder_stacks = global_stack.extruders extruder_stacks = global_stack.extruders
for extruder_key in global_stack.extruders.keys(): for position, extruder_stack in extruder_stacks.keys():
index = int(extruder_key) index = int(position)
if index >= len(self._material_amounts): # Right now the _material_amounts is a list, where the index is the extruder number if index >= len(self._material_amounts): # Right now the _material_amounts is a list, where the index is the extruder number
continue continue
amount = self._material_amounts[index] amount = self._material_amounts[index]
## Find the right extruder stack. As the list isn't sorted because it's a annoying generator, we do some ## Find the right extruder stack. As the list isn't sorted because it's a annoying generator, we do some
# list comprehension filtering to solve this for us. # list comprehension filtering to solve this for us.
extruder_stack = extruder_stacks[str(index)]
density = extruder_stack.getMetaDataEntry("properties", {}).get("density", 0) density = extruder_stack.getMetaDataEntry("properties", {}).get("density", 0)
material = extruder_stack.findContainer({"type": "material"}) material = extruder_stack.findContainer({"type": "material"})