fix for own regression with handling of script paths, however this didnt work quite...
authorCampbell Barton <ideasman42@gmail.com>
Sun, 29 Jul 2012 01:02:25 +0000 (01:02 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 29 Jul 2012 01:02:25 +0000 (01:02 +0000)
Handle these 2 kinds of script paths
* user script path: ~/.blender/scripts OR $BLENDER_USER_SCRIPTS
* pref script path: always bpy.context.user_preferences.filepaths.script_directory

now both are returned by bpy.utils.script_paths()

release/scripts/modules/bpy/utils.py
release/scripts/modules/sys_info.py
release/scripts/startup/bl_ui/space_userpref.py

index ad657284492d23f152ff2f02b29adec212643076..09deb33c174070d80b2620ceb69324874c8d11b1 100644 (file)
@@ -34,13 +34,14 @@ __all__ = (
     "register_class",
     "register_module",
     "resource_path",
+    "script_path_user",
+    "script_path_pref",
     "script_paths",
     "smpte_from_frame",
     "smpte_from_seconds",
     "unregister_class",
     "unregister_module",
     "user_resource",
-    "user_script_path",
     )
 
 from _bpy import register_class, unregister_class, blend_paths, resource_path
@@ -252,15 +253,16 @@ _scripts = _os.path.join(_os.path.dirname(__file__),
 _scripts = (_os.path.normpath(_scripts), )
 
 
-def user_script_path():
-    # returns the env var and falls back to userprefs
+def script_path_user():
+    """returns the env var and falls back to home dir or None"""
     path = _user_resource('SCRIPTS')
+    return _os.path.normpath(path) if path else None
 
-    if path:
-        path = _os.path.normpath(path)
-        return path
-    else:
-        return None
+
+def script_path_pref():
+    """returns the user preference or None"""
+    path = _bpy.context.user_preferences.filepaths.script_directory
+    return _os.path.normpath(path) if path else None
 
 
 def script_paths(subdir=None, user_pref=True, check_all=False):
@@ -278,10 +280,6 @@ def script_paths(subdir=None, user_pref=True, check_all=False):
     :rtype: list
     """
     scripts = list(_scripts)
-    prefs = _bpy.context.user_preferences
-
-    # add user scripts dir
-    user_script = user_script_path()
 
     if check_all:
         # all possible paths
@@ -291,7 +289,7 @@ def script_paths(subdir=None, user_pref=True, check_all=False):
         # only paths blender uses
         base_paths = _bpy_script_paths()
 
-    for path in base_paths + (user_script, ):
+    for path in base_paths + (script_path_user(), script_path_pref()):
         if path:
             path = _os.path.normpath(path)
             if path not in scripts and _os.path.isdir(path):
index 6fc50bcfe0d015aeeeb3b347973ba57d17e3da32..ea75bfde8092c56bcce44c9fad0d07660b96baaf 100644 (file)
@@ -87,7 +87,8 @@ def write_sysinfo(op):
     output.write("\nDirectories:\n")
     output.write(lilies)
     output.write("scripts: %r\n" % (bpy.utils.script_paths()))
-    output.write("user scripts: %r\n" % (bpy.utils.user_script_path()))
+    output.write("user scripts: %r\n" % (bpy.utils.script_path_user()))
+    output.write("pref scripts: %r\n" % (bpy.utils.script_path_pref()))
     output.write("datafiles: %r\n" % (bpy.utils.user_resource('DATAFILES')))
     output.write("config: %r\n" % (bpy.utils.user_resource('CONFIG')))
     output.write("scripts : %r\n" % (bpy.utils.user_resource('SCRIPTS')))
index 66382e72a4dd581a6a0bc7c4033c3125e45ed748..03c86ffafaa013fa6e403d7f87126b52f5c2537d 100644 (file)
@@ -1004,10 +1004,10 @@ class USERPREF_PT_addons(Panel):
     @staticmethod
     def is_user_addon(mod, user_addon_paths):
         if not user_addon_paths:
-            user_script_path = bpy.utils.user_script_path()
-            if user_script_path is not None:
-                user_addon_paths.append(os.path.join(user_script_path, "addons"))
-            user_addon_paths.append(os.path.join(bpy.utils.resource_path('USER'), "scripts", "addons"))
+            for path in (bpy.utils.script_path_user(),
+                         bpy.utils.script_path_pref()):
+                if path is not None:
+                    user_addon_paths.append(os.path.join(path, "addons"))
 
         for path in user_addon_paths:
             if bpy.path.is_subdir(mod.__file__, path):