mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Correct the configparser
The import was missing. Also, the parser was not called on the correct stream. Contributes to issue CURA-37.
This commit is contained in:
parent
57f5e60fa5
commit
f2a95ae89c
1 changed files with 11 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
||||||
# Copyright (c) 2015 Ultimaker B.V.
|
# Copyright (c) 2015 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the AGPLv3 or higher.
|
# Cura is released under the terms of the AGPLv3 or higher.
|
||||||
|
|
||||||
|
import configparser #For reading the legacy profile INI files.
|
||||||
import json #For reading the Dictionary of Doom.
|
import json #For reading the Dictionary of Doom.
|
||||||
|
|
||||||
from UM.Application import Application #To get the machine manager to create the new profile in.
|
from UM.Application import Application #To get the machine manager to create the new profile in.
|
||||||
|
@ -28,9 +29,13 @@ class LegacyProfileReader(ProfileReader):
|
||||||
profile = Profile(machine_manager = Application.getInstance().getMachineManager(), read_only = False) #Create an empty profile.
|
profile = Profile(machine_manager = Application.getInstance().getMachineManager(), read_only = False) #Create an empty profile.
|
||||||
profile.setName("Imported Legacy Profile")
|
profile.setName("Imported Legacy Profile")
|
||||||
|
|
||||||
stream = io.StringIO(serialised) #ConfigParser needs to read from a stream.
|
|
||||||
parser = configparser.ConfigParser(interpolation = None)
|
parser = configparser.ConfigParser(interpolation = None)
|
||||||
parser.readfp(stream)
|
try:
|
||||||
|
with open(file_name) as f:
|
||||||
|
parser.readfp(f) #Parse the INI file.
|
||||||
|
except Exception as e:
|
||||||
|
Logger.log("e", "Unable to open legacy profile %s: %s", file_name, str(e))
|
||||||
|
return None
|
||||||
|
|
||||||
#Legacy Cura saved the profile under the section "profile_N" where N is the ID of a machine, except when you export in which case it saves it in the section "profile".
|
#Legacy Cura saved the profile under the section "profile_N" where N is the ID of a machine, except when you export in which case it saves it in the section "profile".
|
||||||
#Since importing multiple machine profiles is out of scope, just import the first section we find.
|
#Since importing multiple machine profiles is out of scope, just import the first section we find.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue