mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Fix call to prepareLocals
Turns out the 'self.' is required... Contributes to issue CURA-37.
This commit is contained in:
parent
f2a95ae89c
commit
abb92afc27
1 changed files with 22 additions and 22 deletions
|
@ -19,6 +19,25 @@ class LegacyProfileReader(ProfileReader):
|
|||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
## Prepares the local variables that can be used in evaluation of computing
|
||||
# new setting values from the old ones.
|
||||
#
|
||||
# This fills a dictionary with all settings from the legacy Cura version
|
||||
# and their values, so that they can be used in evaluating the new setting
|
||||
# values as Python code.
|
||||
#
|
||||
# \param parser The ConfigParser that finds the settings in the legacy
|
||||
# profile.
|
||||
# \param section The section in the profile where the settings should be
|
||||
# found.
|
||||
# \return A set of local variables, one for each setting in the legacy
|
||||
# profile.
|
||||
def prepareLocals(self, parser, section):
|
||||
locals = {}
|
||||
for option in parser.options():
|
||||
locals[option] = parser.get(section, option)
|
||||
return locals
|
||||
|
||||
## Reads a legacy Cura profile from a file and returns it.
|
||||
#
|
||||
# \param file_name The file to read the legacy Cura profile from.
|
||||
|
@ -41,13 +60,13 @@ class LegacyProfileReader(ProfileReader):
|
|||
#Since importing multiple machine profiles is out of scope, just import the first section we find.
|
||||
section = ""
|
||||
for found_section in parser.sections():
|
||||
if found_section.startsWith("profile"):
|
||||
if found_section.startswith("profile"):
|
||||
section = found_section
|
||||
break
|
||||
if not section: #No section starting with "profile" was found. Probably not a proper INI file.
|
||||
return None
|
||||
|
||||
legacy_settings = prepareLocals(parser, section) #Gets the settings from the legacy profile.
|
||||
legacy_settings = self.prepareLocals(parser, section) #Gets the settings from the legacy profile.
|
||||
|
||||
try:
|
||||
with open(os.path.join(PluginRegistry.getInstance().getPluginPath("LegacyProfileReader"), "DictionaryOfDoom.json"), "r", -1, "utf-8") as f:
|
||||
|
@ -67,23 +86,4 @@ class LegacyProfileReader(ProfileReader):
|
|||
new_value = eval(compiled, {}, legacy_settings) #Pass the legacy settings as local variables to allow access to in the evaluation.
|
||||
profile.setSettingValue(new_setting, new_value) #Store the setting in the profile!
|
||||
|
||||
return profile
|
||||
|
||||
## Prepares the local variables that can be used in evaluation of computing
|
||||
# new setting values from the old ones.
|
||||
#
|
||||
# This fills a dictionary with all settings from the legacy Cura version
|
||||
# and their values, so that they can be used in evaluating the new setting
|
||||
# values as Python code.
|
||||
#
|
||||
# \param parser The ConfigParser that finds the settings in the legacy
|
||||
# profile.
|
||||
# \param section The section in the profile where the settings should be
|
||||
# found.
|
||||
# \return A set of local variables, one for each setting in the legacy
|
||||
# profile.
|
||||
def prepareLocals(self, parser, section):
|
||||
locals = {}
|
||||
for option in parser.options():
|
||||
locals[option] = parser.get(section, option)
|
||||
return locals
|
||||
return profile
|
Loading…
Add table
Add a link
Reference in a new issue