mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-19 12:47:49 -06:00
Correct typing
This commit is contained in:
parent
4dea8fba76
commit
e1a52f841f
1 changed files with 6 additions and 3 deletions
|
@ -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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue