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()
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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')))
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user