mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-22 21:59:37 +08:00
CURA-5330 Fix typing in 3MFReader plugin
This commit is contained in:
parent
f2768fd761
commit
eca23e5b5d
@ -4,7 +4,7 @@
|
|||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
import zipfile
|
import zipfile
|
||||||
import os
|
import os
|
||||||
from typing import List, Tuple
|
from typing import Dict, List, Tuple
|
||||||
|
|
||||||
|
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
@ -38,7 +38,7 @@ i18n_catalog = i18nCatalog("cura")
|
|||||||
|
|
||||||
|
|
||||||
class ContainerInfo:
|
class ContainerInfo:
|
||||||
def __init__(self, file_name: str, serialized: str, parser: ConfigParser):
|
def __init__(self, file_name: str, serialized: str, parser: ConfigParser) -> None:
|
||||||
self.file_name = file_name
|
self.file_name = file_name
|
||||||
self.serialized = serialized
|
self.serialized = serialized
|
||||||
self.parser = parser
|
self.parser = parser
|
||||||
@ -47,14 +47,14 @@ class ContainerInfo:
|
|||||||
|
|
||||||
|
|
||||||
class QualityChangesInfo:
|
class QualityChangesInfo:
|
||||||
def __init__(self):
|
def __init__(self) -> None:
|
||||||
self.name = None
|
self.name = None
|
||||||
self.global_info = None
|
self.global_info = None
|
||||||
self.extruder_info_dict = {}
|
self.extruder_info_dict = {} # type: Dict[str, ContainerInfo]
|
||||||
|
|
||||||
|
|
||||||
class MachineInfo:
|
class MachineInfo:
|
||||||
def __init__(self):
|
def __init__(self) -> None:
|
||||||
self.container_id = None
|
self.container_id = None
|
||||||
self.name = None
|
self.name = None
|
||||||
self.definition_id = None
|
self.definition_id = None
|
||||||
@ -66,11 +66,11 @@ class MachineInfo:
|
|||||||
self.definition_changes_info = None
|
self.definition_changes_info = None
|
||||||
self.user_changes_info = None
|
self.user_changes_info = None
|
||||||
|
|
||||||
self.extruder_info_dict = {}
|
self.extruder_info_dict = {} # type: Dict[str, ExtruderInfo]
|
||||||
|
|
||||||
|
|
||||||
class ExtruderInfo:
|
class ExtruderInfo:
|
||||||
def __init__(self):
|
def __init__(self) -> None:
|
||||||
self.position = None
|
self.position = None
|
||||||
self.enabled = True
|
self.enabled = True
|
||||||
self.variant_info = None
|
self.variant_info = None
|
||||||
@ -82,7 +82,7 @@ class ExtruderInfo:
|
|||||||
|
|
||||||
## Base implementation for reading 3MF workspace files.
|
## Base implementation for reading 3MF workspace files.
|
||||||
class ThreeMFWorkspaceReader(WorkspaceReader):
|
class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
def __init__(self):
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
MimeTypeDatabase.addMimeType(
|
MimeTypeDatabase.addMimeType(
|
||||||
@ -112,28 +112,26 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
# - variant
|
# - variant
|
||||||
self._ignored_instance_container_types = {"quality", "variant"}
|
self._ignored_instance_container_types = {"quality", "variant"}
|
||||||
|
|
||||||
self._resolve_strategies = {}
|
self._resolve_strategies = {} # type: Dict[str, str]
|
||||||
|
|
||||||
self._id_mapping = {}
|
self._id_mapping = {} # type: Dict[str, str]
|
||||||
|
|
||||||
# In Cura 2.5 and 2.6, the empty profiles used to have those long names
|
# In Cura 2.5 and 2.6, the empty profiles used to have those long names
|
||||||
self._old_empty_profile_id_dict = {"empty_%s" % k: "empty" for k in ["material", "variant"]}
|
self._old_empty_profile_id_dict = {"empty_%s" % k: "empty" for k in ["material", "variant"]}
|
||||||
|
|
||||||
self._is_same_machine_type = False
|
self._is_same_machine_type = False
|
||||||
self._old_new_materials = {}
|
self._old_new_materials = {} # type: Dict[str, str]
|
||||||
self._materials_to_select = {}
|
|
||||||
self._machine_info = None
|
self._machine_info = None
|
||||||
|
|
||||||
def _clearState(self):
|
def _clearState(self):
|
||||||
self._is_same_machine_type = False
|
self._is_same_machine_type = False
|
||||||
self._id_mapping = {}
|
self._id_mapping = {}
|
||||||
self._old_new_materials = {}
|
self._old_new_materials = {}
|
||||||
self._materials_to_select = {}
|
|
||||||
self._machine_info = None
|
self._machine_info = None
|
||||||
|
|
||||||
## Get a unique name based on the old_id. This is different from directly calling the registry in that it caches results.
|
## Get a unique name based on the old_id. This is different from directly calling the registry in that it caches results.
|
||||||
# This has nothing to do with speed, but with getting consistent new naming for instances & objects.
|
# This has nothing to do with speed, but with getting consistent new naming for instances & objects.
|
||||||
def getNewId(self, old_id):
|
def getNewId(self, old_id: str):
|
||||||
if old_id not in self._id_mapping:
|
if old_id not in self._id_mapping:
|
||||||
self._id_mapping[old_id] = self._container_registry.uniqueName(old_id)
|
self._id_mapping[old_id] = self._container_registry.uniqueName(old_id)
|
||||||
return self._id_mapping[old_id]
|
return self._id_mapping[old_id]
|
||||||
@ -671,7 +669,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
else:
|
else:
|
||||||
material_container = materials[0]
|
material_container = materials[0]
|
||||||
old_material_root_id = material_container.getMetaDataEntry("base_file")
|
old_material_root_id = material_container.getMetaDataEntry("base_file")
|
||||||
if not self._container_registry.isReadOnly(old_material_root_id): # Only create new materials if they are not read only.
|
if old_material_root_id is not None and not self._container_registry.isReadOnly(old_material_root_id): # Only create new materials if they are not read only.
|
||||||
to_deserialize_material = True
|
to_deserialize_material = True
|
||||||
|
|
||||||
if self._resolve_strategies["material"] == "override":
|
if self._resolve_strategies["material"] == "override":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user