diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-07-25 13:50:12 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-07-25 13:52:08 +0300 |
commit | edc6bec9d60204cb81d2e7533402630b076d0d32 (patch) | |
tree | bd3740b59643e5195b6cb15a310430b65ccd40bf /release/scripts/modules/bpy/utils/__init__.py | |
parent | 35d9f681213c56429829afa01b13ee77d621e9d3 (diff) |
PyAPI: Skip user scripts w/ factory-startup
Adds bpy.app.factory_startup,
used to check if user scripts should be loaded.
Diffstat (limited to 'release/scripts/modules/bpy/utils/__init__.py')
-rw-r--r-- | release/scripts/modules/bpy/utils/__init__.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/release/scripts/modules/bpy/utils/__init__.py b/release/scripts/modules/bpy/utils/__init__.py index 703a61f72f5..6d3e807c2b4 100644 --- a/release/scripts/modules/bpy/utils/__init__.py +++ b/release/scripts/modules/bpy/utils/__init__.py @@ -72,6 +72,7 @@ import addon_utils as _addon_utils _user_preferences = _bpy.context.user_preferences _script_module_dirs = "startup", "modules" +_is_factory_startup = _bpy.app.factory_startup def _test_import(module_name, loaded_modules): @@ -145,6 +146,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): :type refresh_scripts: bool """ use_time = use_class_register_check = _bpy.app.debug_python + use_user = not _is_factory_startup if use_time: import time @@ -235,7 +237,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): from bpy_restrict_state import RestrictBlend with RestrictBlend(): - for base_path in script_paths(): + for base_path in script_paths(use_user=use_user): for path_subdir in _script_module_dirs: path = _os.path.join(base_path, path_subdir) if _os.path.isdir(path): @@ -307,7 +309,7 @@ def script_path_pref(): return _os.path.normpath(path) if path else None -def script_paths(subdir=None, user_pref=True, check_all=False): +def script_paths(subdir=None, user_pref=True, check_all=False, use_user=True): """ Returns a list of valid script paths. @@ -331,13 +333,24 @@ def script_paths(subdir=None, user_pref=True, check_all=False): if check_all: # All possible paths, no duplicates, keep order. + if use_user: + test_paths = ('LOCAL', 'USER', 'SYSTEM') + else: + test_paths = ('LOCAL', 'SYSTEM') + base_paths = ( - *(path for path in (_os.path.join(resource_path(res), "scripts") - for res in ('LOCAL', 'USER', 'SYSTEM')) if path not in base_paths), + *(path for path in ( + _os.path.join(resource_path(res), "scripts") + for res in test_paths) if path not in base_paths), *base_paths, - ) + ) + + if use_user: + test_paths = (*base_paths, script_path_user(), script_path_pref()) + else: + test_paths = (*base_paths, script_path_pref()) - for path in (*base_paths, script_path_user(), script_path_pref()): + for path in test_paths: if path: path = _os.path.normpath(path) if path not in scripts and _os.path.isdir(path): |