diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-29 05:02:25 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-29 05:02:25 +0400 |
commit | 3270438678c8022c00de9655300b9589803a50b1 (patch) | |
tree | e6ae4321da08e1257b16c396a0170b18569a1a52 /release/scripts/modules/bpy | |
parent | f5d643e950892760d7c82aaee8a7e31bba8a8359 (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/scripts/modules/bpy')
-rw-r--r-- | release/scripts/modules/bpy/utils.py | 24 |
1 files changed, 11 insertions, 13 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): |