Correct typing

This commit is contained in:
Lipu Fei 2019-09-16 10:43:22 +02:00
parent 4dea8fba76
commit e1a52f841f

View file

@ -287,7 +287,8 @@ class MaterialManager(QObject):
if root_material_id is not None: if root_material_id is not None:
self.removeMaterialByRootId(root_material_id) self.removeMaterialByRootId(root_material_id)
def duplicateMaterialByRootId(self, root_material_id, new_base_id: Optional[str] = None, new_metadata: Dict[str, Any] = None) -> Optional[str]: def duplicateMaterialByRootId(self, root_material_id: str, new_base_id: Optional[str] = None,
new_metadata: Optional[Dict[str, Any]] = None) -> Optional[str]:
container_registry = CuraContainerRegistry.getInstance() container_registry = CuraContainerRegistry.getInstance()
results = container_registry.findContainers(id=root_material_id) results = container_registry.findContainers(id=root_material_id)
@ -346,12 +347,14 @@ class MaterialManager(QObject):
# Returns the root material ID of the duplicated material if successful. # Returns the root material ID of the duplicated material if successful.
# #
@pyqtSlot("QVariant", result = str) @pyqtSlot("QVariant", result = str)
def duplicateMaterial(self, material_node: MaterialNode, new_base_id: Optional[str] = None, new_metadata: Dict[str, Any] = None) -> Optional[str]: def duplicateMaterial(self, material_node: MaterialNode, new_base_id: Optional[str] = None,
new_metadata: Optional[Dict[str, Any]] = None) -> str:
if material_node.container is None: if material_node.container is None:
Logger.log("e", "Material node {0} doesn't have container.".format(material_node.container_id)) Logger.log("e", "Material node {0} doesn't have container.".format(material_node.container_id))
return "ERROR" return "ERROR"
root_material_id = cast(str, material_node.container.getMetaDataEntry("base_file", "")) root_material_id = cast(str, material_node.container.getMetaDataEntry("base_file", ""))
return self.duplicateMaterialByRootId(root_material_id, new_base_id, new_metadata) new_material_id = self.duplicateMaterialByRootId(root_material_id, new_base_id, new_metadata)
return new_material_id if new_material_id is not None else "ERROR"
# Create a new material by cloning Generic PLA for the current material diameter and generate a new GUID. # Create a new material by cloning Generic PLA for the current material diameter and generate a new GUID.
# Returns the ID of the newly created material. # Returns the ID of the newly created material.