mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 01:07:52 -06:00
Use ConfigParser hack to replace connect_signals=False hack
CURA-3756
This commit is contained in:
parent
0d76ce72b0
commit
acde348c6d
1 changed files with 14 additions and 9 deletions
|
@ -18,6 +18,7 @@ from cura.Settings.ExtruderManager import ExtruderManager
|
||||||
from cura.Settings.ExtruderStack import ExtruderStack
|
from cura.Settings.ExtruderStack import ExtruderStack
|
||||||
from cura.Settings.GlobalStack import GlobalStack
|
from cura.Settings.GlobalStack import GlobalStack
|
||||||
|
|
||||||
|
from configparser import ConfigParser
|
||||||
import zipfile
|
import zipfile
|
||||||
import io
|
import io
|
||||||
import configparser
|
import configparser
|
||||||
|
@ -67,16 +68,20 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
files_to_determine = [name for name in file_list if name.endswith(self._container_stack_suffix)]
|
files_to_determine = [name for name in file_list if name.endswith(self._container_stack_suffix)]
|
||||||
for file_name in files_to_determine:
|
for file_name in files_to_determine:
|
||||||
container_id = self._stripFileToId(file_name)
|
container_id = self._stripFileToId(file_name)
|
||||||
stack = ContainerStack(container_id)
|
# FIXME: HACK!
|
||||||
# Deserialize stack by converting read data from bytes to string
|
# We need to know the type of the stack file, but we can only know it if we deserialize it.
|
||||||
#
|
# The default ContainerStack.deserialize() will connect signals, which is not desired in this case.
|
||||||
# NOTE: We do not connect the signals here is because all deserialized stacks here are NOT registered
|
# Since we know that the stack files are INI files, so we directly use the ConfigParser to parse them.
|
||||||
# in the ContainerRegistry. So, some stacks from the profile won't be found in the ContainerRegistry,
|
serialized = archive.open(file_name).read().decode("utf-8")
|
||||||
# and thus failing the signal connecting.
|
stack_config = ConfigParser()
|
||||||
#
|
stack_config.read_string(serialized)
|
||||||
stack.deserialize(archive.open(file_name).read().decode("utf-8"), connect_signals=False)
|
|
||||||
|
|
||||||
stack_type = stack.getMetaDataEntry("type")
|
# sanity check
|
||||||
|
if not stack_config.has_option("metadata", "type"):
|
||||||
|
Logger.log("e", "%s in %s doesn't seem to be valid stack file", file_name, project_file_name)
|
||||||
|
continue
|
||||||
|
|
||||||
|
stack_type = stack_config.get("metadata", "type")
|
||||||
if stack_type == "extruder_train":
|
if stack_type == "extruder_train":
|
||||||
extruder_stack_file_list.append(file_name)
|
extruder_stack_file_list.append(file_name)
|
||||||
elif stack_type == "machine":
|
elif stack_type == "machine":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue