Add cfg folder for keyconfigs (and possibly others later) to be imported after everyt...
authorMartin Poirier <theeth@yahoo.com>
Thu, 28 Jan 2010 21:52:07 +0000 (21:52 +0000)
committerMartin Poirier <theeth@yahoo.com>
Thu, 28 Jan 2010 21:52:07 +0000 (21:52 +0000)
Also remove .pyc file when removing keyconfigs.

release/scripts/modules/bpy/utils.py
release/scripts/ui/space_userpref.py

index 383d2be0780d9467c5adfb821f15e8da36c814fe..38de95aa6e49e227e4314b3b93a287f5a09cce35 100644 (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):
 
index 52b8d6583eabda706630a70ad648cec034d6b95a..292d855b96c80ee2ca9c8341722109e0257a4375 100644 (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'}