mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
CURA-5330 Fix typing in 3MFReader plugin
This commit is contained in:
parent
f2768fd761
commit
eca23e5b5d
1 changed files with 13 additions and 15 deletions
|
@ -4,7 +4,7 @@
|
|||
from configparser import ConfigParser
|
||||
import zipfile
|
||||
import os
|
||||
from typing import List, Tuple
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
|
||||
import xml.etree.ElementTree as ET
|
||||
|
@ -38,7 +38,7 @@ i18n_catalog = i18nCatalog("cura")
|
|||
|
||||
|
||||
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.serialized = serialized
|
||||
self.parser = parser
|
||||
|
@ -47,14 +47,14 @@ class ContainerInfo:
|
|||
|
||||
|
||||
class QualityChangesInfo:
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
self.name = None
|
||||
self.global_info = None
|
||||
self.extruder_info_dict = {}
|
||||
self.extruder_info_dict = {} # type: Dict[str, ContainerInfo]
|
||||
|
||||
|
||||
class MachineInfo:
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
self.container_id = None
|
||||
self.name = None
|
||||
self.definition_id = None
|
||||
|
@ -66,11 +66,11 @@ class MachineInfo:
|
|||
self.definition_changes_info = None
|
||||
self.user_changes_info = None
|
||||
|
||||
self.extruder_info_dict = {}
|
||||
self.extruder_info_dict = {} # type: Dict[str, ExtruderInfo]
|
||||
|
||||
|
||||
class ExtruderInfo:
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
self.position = None
|
||||
self.enabled = True
|
||||
self.variant_info = None
|
||||
|
@ -82,7 +82,7 @@ class ExtruderInfo:
|
|||
|
||||
## Base implementation for reading 3MF workspace files.
|
||||
class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||
def __init__(self):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
|
||||
MimeTypeDatabase.addMimeType(
|
||||
|
@ -112,28 +112,26 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||
# - 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
|
||||
self._old_empty_profile_id_dict = {"empty_%s" % k: "empty" for k in ["material", "variant"]}
|
||||
|
||||
self._is_same_machine_type = False
|
||||
self._old_new_materials = {}
|
||||
self._materials_to_select = {}
|
||||
self._old_new_materials = {} # type: Dict[str, str]
|
||||
self._machine_info = None
|
||||
|
||||
def _clearState(self):
|
||||
self._is_same_machine_type = False
|
||||
self._id_mapping = {}
|
||||
self._old_new_materials = {}
|
||||
self._materials_to_select = {}
|
||||
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.
|
||||
# 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:
|
||||
self._id_mapping[old_id] = self._container_registry.uniqueName(old_id)
|
||||
return self._id_mapping[old_id]
|
||||
|
@ -671,7 +669,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||
else:
|
||||
material_container = materials[0]
|
||||
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
|
||||
|
||||
if self._resolve_strategies["material"] == "override":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue