diff options
author | Simon Edwards <s.edwards@ultimaker.com> | 2016-12-12 18:05:35 +0300 |
---|---|---|
committer | Simon Edwards <s.edwards@ultimaker.com> | 2016-12-12 18:05:35 +0300 |
commit | 74e5798509b274908fc98b704fdc7848c6ab4e27 (patch) | |
tree | 8e31c1e4cc408496ba4894915b0a12f5cb14e3fd /cura/QualityManager.py | |
parent | 5884509af1f785d6c48b0af294ae9a989ecb2155 (diff) |
Lots of import fixes. Eliminated the import hacks such as those used inside UM/Settings/__init__.py.
CURA-2917
Diffstat (limited to 'cura/QualityManager.py')
-rw-r--r-- | cura/QualityManager.py | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/cura/QualityManager.py b/cura/QualityManager.py index 5b4d743ae9..dc23b2bafa 100644 --- a/cura/QualityManager.py +++ b/cura/QualityManager.py @@ -1,12 +1,16 @@ # Copyright (c) 2016 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher.
-import UM.Application
-import cura.Settings.ExtruderManager
-import UM.Settings.ContainerRegistry
-
# This collects a lot of quality and quality changes related code which was split between ContainerManager
# and the MachineManager and really needs to usable from both.
+from typing import List
+
+from UM.Application import Application
+from UM.Settings.ContainerRegistry import ContainerRegistry
+from UM.Settings.DefinitionContainer import DefinitionContainer
+from UM.Settings.InstanceContainer import InstanceContainer
+from cura.Settings.ExtruderManager import ExtruderManager
+
class QualityManager:
@@ -121,14 +125,14 @@ class QualityManager: #
# \param machine_definition \type{DefinitionContainer} the machine definition.
# \return \type{List[InstanceContainer]} the list of quality changes
- def findAllQualityChangesForMachine(self, machine_definition):
+ def findAllQualityChangesForMachine(self, machine_definition: DefinitionContainer) -> List[InstanceContainer]:
if machine_definition.getMetaDataEntry("has_machine_quality"):
definition_id = machine_definition.getId()
else:
definition_id = "fdmprinter"
filter_dict = { "type": "quality_changes", "extruder": None, "definition": definition_id }
- quality_changes_list = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(**filter_dict)
+ quality_changes_list = ContainerRegistry.getInstance().findInstanceContainers(**filter_dict)
return quality_changes_list
## Find all usable qualities for a machine and extruders.
@@ -177,7 +181,7 @@ class QualityManager: if base_material:
# There is a basic material specified
criteria = { "type": "material", "name": base_material, "definition": definition_id }
- containers = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(**criteria)
+ containers = ContainerRegistry.getInstance().findInstanceContainers(**criteria)
containers = [basic_material for basic_material in containers if
basic_material.getMetaDataEntry("variant") == material_container.getMetaDataEntry(
"variant")]
@@ -191,13 +195,13 @@ class QualityManager: def _getFilteredContainersForStack(self, machine_definition=None, material_containers=None, **kwargs):
# Fill in any default values.
if machine_definition is None:
- machine_definition = UM.Application.getInstance().getGlobalContainerStack().getBottom()
+ machine_definition = Application.getInstance().getGlobalContainerStack().getBottom()
quality_definition_id = machine_definition.getMetaDataEntry("quality_definition")
if quality_definition_id is not None:
- machine_definition = UM.Settings.ContainerRegistry.getInstance().findDefinitionContainers(id=quality_definition_id)[0]
+ machine_definition = ContainerRegistry.getInstance().findDefinitionContainers(id=quality_definition_id)[0]
if material_containers is None:
- active_stacks = cura.Settings.ExtruderManager.getInstance().getActiveGlobalAndExtruderStacks()
+ active_stacks = ExtruderManager.getInstance().getActiveGlobalAndExtruderStacks()
material_containers = [stack.findContainer(type="material") for stack in active_stacks]
criteria = kwargs
@@ -222,7 +226,7 @@ class QualityManager: if material_instance is not None:
material_ids.add(material_instance.getId())
- containers = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(**criteria)
+ containers = ContainerRegistry.getInstance().findInstanceContainers(**criteria)
result = []
for container in containers:
@@ -238,8 +242,8 @@ class QualityManager: # an extruder definition.
# \return \type{DefinitionContainer} the parent machine definition. If the given machine
# definition doesn't have a parent then it is simply returned.
- def getParentMachineDefinition(self, machine_definition):
- container_registry = UM.Settings.ContainerRegistry.getInstance()
+ def getParentMachineDefinition(self, machine_definition: DefinitionContainer) -> DefinitionContainer:
+ container_registry = ContainerRegistry.getInstance()
machine_entry = machine_definition.getMetaDataEntry("machine")
if machine_entry is None:
@@ -274,6 +278,6 @@ class QualityManager: # This already is a 'global' machine definition.
return machine_definition
else:
- container_registry = UM.Settings.ContainerRegistry.getInstance()
+ container_registry = ContainerRegistry.getInstance()
whole_machine = container_registry.findDefinitionContainers(id=machine_entry)[0]
return whole_machine
|