Cleanup: use more descriptive names for module test exclusion

Include comments for how exclusion works.
This commit is contained in:
Campbell Barton
2024-05-16 15:49:23 +10:00
parent 6e6ce17e34
commit ccb1fcb5a5

View File

@@ -14,7 +14,10 @@ import addon_utils
import sys
import os
BLACKLIST = {
# Modules to exclude relative to their location in `sys.path`.
# The trailing components of the path are used instead of the module name.
# Both script files & directories are supported which prevents searching inside the directory.
EXCLUDE_MODULE_PATHS = {
"bl_i18n_utils",
"bl_previews_utils",
"cycles",
@@ -34,12 +37,12 @@ MODULE_SYS_PATHS = {
}
if not bpy.app.build_options.freestyle:
BLACKLIST.add("render_freestyle_svg")
EXCLUDE_MODULE_PATHS.add("render_freestyle_svg")
if not bpy.app.build_options.xr_openxr:
BLACKLIST.add("viewport_vr_preview")
EXCLUDE_MODULE_PATHS.add("viewport_vr_preview")
BLACKLIST_DIRS = (
EXCLUDE_MODULE_DIRS = (
os.path.join(bpy.utils.user_resource('SCRIPTS')),
) + tuple(addon_utils.paths()[1:])
@@ -102,7 +105,7 @@ def load_modules():
for script_path in paths:
for mod_dir in sys.path:
if mod_dir.startswith(script_path):
if not mod_dir.startswith(BLACKLIST_DIRS):
if not mod_dir.startswith(EXCLUDE_MODULE_DIRS):
if mod_dir not in module_paths:
if os.path.exists(mod_dir):
module_paths.append(mod_dir)
@@ -113,7 +116,7 @@ def load_modules():
for mod_dir in module_paths:
# print("mod_dir", mod_dir)
for mod, mod_full in bpy.path.module_names(mod_dir):
if mod in BLACKLIST:
if mod in EXCLUDE_MODULE_PATHS:
continue
if mod in module_names:
mod_dir_prev, mod_full_prev = module_names[mod]
@@ -132,8 +135,8 @@ def load_modules():
os.sep + "templates_osl" + os.sep,
os.sep + "templates_py" + os.sep,
os.sep + "bl_app_templates_system" + os.sep,
] + ([(os.sep + f + os.sep) for f in BLACKLIST] +
[(os.sep + f + ".py") for f in BLACKLIST])
] + ([(os.sep + f + os.sep) for f in EXCLUDE_MODULE_PATHS] +
[(os.sep + f + ".py") for f in EXCLUDE_MODULE_PATHS])
#
# now submodules