Merge branch 'feature_intent_container_tree' of github.com:Ultimaker/Cura into feature_intent_container_tree

This commit is contained in:
Jaime van Kessel 2019-09-18 14:39:30 +02:00
commit ede007b860
No known key found for this signature in database
GPG Key ID: 3710727397403C91

View File

@ -69,9 +69,9 @@ class SendMaterialJob(Job):
def _sendMaterials(self, materials_to_send: Set[str]) -> None: def _sendMaterials(self, materials_to_send: Set[str]) -> None:
container_registry = CuraApplication.getInstance().getContainerRegistry() container_registry = CuraApplication.getInstance().getContainerRegistry()
all_materials = container_registry.findInstanceContainersMetadata(type = "material") all_materials = container_registry.findInstanceContainersMetadata(type = "material")
all_root_materials = {material["base_file"] for material in all_materials if "base_file" in material} # Filters out uniques by making it a set. Don't include files without base file (i.e. empty material). all_base_files = {material["base_file"] for material in all_materials if "base_file" in material} # Filters out uniques by making it a set. Don't include files without base file (i.e. empty material).
for root_material_id in all_root_materials: for root_material_id in all_base_files:
if root_material_id not in materials_to_send: if root_material_id not in materials_to_send:
# If the material does not have to be sent we skip it. # If the material does not have to be sent we skip it.
continue continue
@ -129,10 +129,10 @@ class SendMaterialJob(Job):
def _getLocalMaterials() -> Dict[str, LocalMaterial]: def _getLocalMaterials() -> Dict[str, LocalMaterial]:
result = {} # type: Dict[str, LocalMaterial] result = {} # type: Dict[str, LocalMaterial]
all_materials = CuraApplication.getInstance().getContainerRegistry().findInstanceContainersMetadata(type = "material") all_materials = CuraApplication.getInstance().getContainerRegistry().findInstanceContainersMetadata(type = "material")
all_root_materials = [material for material in all_materials if material["id"] == material.get("base_file")] # Don't send materials without base_file: The empty material doesn't need to be sent. all_base_files = [material for material in all_materials if material["id"] == material.get("base_file")] # Don't send materials without base_file: The empty material doesn't need to be sent.
# Find the latest version of all material containers in the registry. # Find the latest version of all material containers in the registry.
for material_metadata in all_root_materials: for material_metadata in all_base_files:
try: try:
# material version must be an int # material version must be an int
material_metadata["version"] = int(material_metadata["version"]) material_metadata["version"] = int(material_metadata["version"])