CURA-5330 Add typing checks to the MachineManager

This commit is contained in:
Diego Prado Gesto 2018-06-12 16:28:39 +02:00
parent 2dfedf3ae4
commit 2e174e75fa
2 changed files with 68 additions and 22 deletions

View file

@ -1,7 +1,7 @@
# Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from typing import Optional
from typing import Optional, Any, Dict
from collections import OrderedDict
@ -23,11 +23,17 @@ from UM.Settings.InstanceContainer import InstanceContainer
class ContainerNode:
__slots__ = ("metadata", "container", "children_map")
def __init__(self, metadata: Optional[dict] = None):
def __init__(self, metadata: Optional[Dict[str, Any]] = None):
self.metadata = metadata
self.container = None
self.children_map = OrderedDict()
## Get an entry value from the metadata
def getMetaDataEntry(self, entry: str, default: Any = None) -> Any:
if self.metadata is None:
return default
return self.metadata.get(entry, default)
def getChildNode(self, child_key: str) -> Optional["ContainerNode"]:
return self.children_map.get(child_key)