- presets were not being written with 'import bpy' at the start.

- attribute save_keyconfig defaulted to True when unset, not sure why, but .
- use repr() rather then str() so strings are quoted without manually checking. also converts less common chars properly \m \" etc.
This commit is contained in:
Campbell Barton 2010-07-12 18:15:48 +00:00
parent a586541d74
commit 3b81c67353

@ -47,19 +47,17 @@ class AddPresetBase(bpy.types.Operator):
target_path = bpy.utils.preset_paths(self.preset_subdir)[0] # we need some way to tell the user and system preset path
filepath = os.path.join(target_path, filename)
if getattr(self, "save_keyconfig", True):
if getattr(self, "save_keyconfig", False):
bpy.ops.wm.keyconfig_export(filepath=filepath, kc_name=self.properties.name)
file_preset = open(filepath, 'a')
file_preset.write("wm.active_keyconfig = kc\n\n")
else:
file_preset = open(filepath, 'w')
file_preset.write("import bpy\n")
for rna_path in self.preset_values:
value = eval(rna_path)
if type(value) == str:
value = "'%s'" % value
file_preset.write("%s = %s\n" % (rna_path, value))
file_preset.write("%s = %s\n" % (rna_path, repr(value)))
file_preset.close()