Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-07-29 05:02:25 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-07-29 05:02:25 +0400
commit3270438678c8022c00de9655300b9589803a50b1 (patch)
treee6ae4321da08e1257b16c396a0170b18569a1a52 /release
parentf5d643e950892760d7c82aaee8a7e31bba8a8359 (diff)
fix for own regression with handling of script paths, however this didnt work quite right before either.
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()
Diffstat (limited to 'release')
-rw-r--r--release/scripts/modules/bpy/utils.py24
-rw-r--r--release/scripts/modules/sys_info.py3
-rw-r--r--release/scripts/startup/bl_ui/space_userpref.py8
3 files changed, 17 insertions, 18 deletions
diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py
index ad657284492..09deb33c174 100644
--- a/release/scripts/modules/bpy/utils.py
+++ b/release/scripts/modules/bpy/utils.py
@@ -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):
diff --git a/release/scripts/modules/sys_info.py b/release/scripts/modules/sys_info.py
index 6fc50bcfe0d..ea75bfde809 100644
--- a/release/scripts/modules/sys_info.py
+++ b/release/scripts/modules/sys_info.py
@@ -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')))
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 66382e72a4d..03c86ffafaa 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -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):