Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/cura
diff options
context:
space:
mode:
authorJelle Spijker <j.spijker@ultimaker.com>2022-06-14 12:44:18 +0300
committerJelle Spijker <j.spijker@ultimaker.com>2022-06-14 12:44:18 +0300
commit93e58d55fa3a09dcc953191fc345e9b4b0bb8575 (patch)
treed1fd4d509ee5fa5c2e2e5ab3a1f8aa37a9a1571e /cura
parentffca22971e5957f9cbe93dfc3f4c276df284a7d1 (diff)
parent90bb02acaea4a12307488c6e29760b580e95996b (diff)
Merge branch 'main' into CURA-9365_fix_building_cura_main
Diffstat (limited to 'cura')
-rw-r--r--cura/CuraPackageManager.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/cura/CuraPackageManager.py b/cura/CuraPackageManager.py
index e23ed47ffa..87a2935d96 100644
--- a/cura/CuraPackageManager.py
+++ b/cura/CuraPackageManager.py
@@ -1,7 +1,9 @@
# Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
+import glob
import os
+from pathlib import Path
from typing import Any, cast, Dict, List, Set, Tuple, TYPE_CHECKING, Optional
from UM.Logger import Logger
@@ -55,6 +57,26 @@ class CuraPackageManager(PackageManager):
super().initialize()
+ def isMaterialBundled(self, file_name: str, guid: str):
+ """ Check if there is a bundled material name with file_name and guid """
+ for path in Resources.getSecureSearchPaths():
+ # Secure search paths are install directory paths, if a material is in here it must be bundled.
+
+ paths = [Path(p) for p in glob.glob(path + '/**/*.xml.fdm_material')]
+ for material in paths:
+ if material.name == file_name:
+ with open(str(material), encoding="utf-8") as f:
+ # Make sure the file we found has the same guid as our material
+ # Parsing this xml would be better but the namespace is needed to search it.
+ parsed_guid = PluginRegistry.getInstance().getPluginObject(
+ "XmlMaterialProfile").getMetadataFromSerialized(
+ f.read(), "GUID")
+ if guid == parsed_guid:
+ # The material we found matches both filename and GUID
+ return True
+
+ return False
+
def getMaterialFilePackageId(self, file_name: str, guid: str) -> str:
"""Get the id of the installed material package that contains file_name"""
for material_package in [f for f in os.scandir(self._installation_dirs_dict["materials"]) if f.is_dir()]: