mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Fix importing math to eval
We expose only math, so it can do mathematical operations on the setting values when translating. Contributes to issue CURA-37.
This commit is contained in:
parent
bfa332e227
commit
0454b37243
1 changed files with 2 additions and 1 deletions
|
@ -3,6 +3,7 @@
|
|||
|
||||
import configparser #For reading the legacy profile INI files.
|
||||
import json #For reading the Dictionary of Doom.
|
||||
import math #For mathematical operations included in the Dictionary of Doom.
|
||||
import os.path #For concatenating the path to the plugin and the relative path to the Dictionary of Doom.
|
||||
|
||||
from UM.Application import Application #To get the machine manager to create the new profile in.
|
||||
|
@ -87,7 +88,7 @@ class LegacyProfileReader(ProfileReader):
|
|||
for new_setting in dict_of_doom["translation"]: #Evaluate all new settings that would get a value from the translations.
|
||||
old_setting_expression = dict_of_doom["translation"][new_setting]
|
||||
compiled = compile(old_setting_expression, new_setting, "eval")
|
||||
new_value = eval(compiled, {}, legacy_settings) #Pass the legacy settings as local variables to allow access to in the evaluation.
|
||||
new_value = eval(compiled, {"math": math}, 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
|
Loading…
Add table
Add a link
Reference in a new issue