Add cfg folder for keyconfigs (and possibly others later) to be imported after everything else.

Also remove .pyc file when removing keyconfigs.
This commit is contained in:
2010-01-28 21:52:07 +00:00
parent 462e7cdb47
commit 21b7556bf7
2 changed files with 13 additions and 6 deletions

View File

@@ -72,7 +72,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False):
test_reload(_sys.modules[module_name])
for base_path in script_paths():
for path_subdir in ("ui", "op", "io"):
for path_subdir in ("ui", "op", "io", "cfg"):
path = _os.path.join(base_path, path_subdir)
if _os.path.isdir(path):

View File

@@ -1502,12 +1502,14 @@ class WM_OT_keyconfig_import(bpy.types.Operator):
f.close()
path = bpy.context.user_preferences.filepaths.python_scripts_directory
path = os.path.split(os.path.split(__file__)[0])[0] # remove ui/space_userpref.py
path = os.path.join(path, "cfg")
if not path:
path = os.path.split(__file__)[0]
path += os.path.sep + config_name + ".py"
# create config folder if needed
if not os.path.exists(path):
os.mkdir(path)
path = os.path.join(path, config_name + ".py")
if self.properties.keep_original:
shutil.copy(self.properties.path, path)
@@ -1717,6 +1719,11 @@ class WM_OT_keyconfig_remove(bpy.types.Operator):
module = __import__(keyconfig.name)
os.remove(module.__file__)
compiled_path = module.__file__ + "c" # for .pyc
if os.path.exists(compiled_path):
os.remove(compiled_path)
wm.remove_keyconfig(keyconfig)
return {'FINISHED'}