Cleanup: assign a variable for the extension module with a trailing "."
This is used in enough places to simplify checks.
This commit is contained in:
@@ -380,8 +380,8 @@ def enable(module_name, *, default_set=False, persistent=False, handle_error=Non
|
||||
print("Add-on not loaded: \"%s\", cause: %s" % (module_name, str(ex)))
|
||||
|
||||
# Issue with an add-on from an extension repository, report a useful message.
|
||||
elif module_name.startswith(ex.name + ".") and module_name.startswith(_ext_base_pkg_idname + "."):
|
||||
repo_id = module_name[len(_ext_base_pkg_idname) + 1:].rpartition(".")[0]
|
||||
elif module_name.startswith(ex.name + ".") and module_name.startswith(_ext_base_pkg_idname_with_dot):
|
||||
repo_id = module_name[len(_ext_base_pkg_idname_with_dot):].rpartition(".")[0]
|
||||
repo = next(
|
||||
(repo for repo in _preferences.filepaths.extension_repos if repo.module == repo_id),
|
||||
None,
|
||||
@@ -632,6 +632,7 @@ class _ext_global:
|
||||
|
||||
# The name (in `sys.modules`) keep this short because it's stored as part of add-on modules name.
|
||||
_ext_base_pkg_idname = "bl_ext"
|
||||
_ext_base_pkg_idname_with_dot = _ext_base_pkg_idname + "."
|
||||
|
||||
|
||||
def _extension_preferences_idmap():
|
||||
@@ -692,12 +693,11 @@ def _initialize_extension_repos_post_addons_prepare(
|
||||
# All preferences info.
|
||||
# Map: `repo_id -> {submodule_id -> addon, ...}`.
|
||||
addon_userdef_info = {}
|
||||
module_prefix = _ext_base_pkg_idname + "."
|
||||
for addon in _preferences.addons:
|
||||
module = addon.module
|
||||
if not module.startswith(module_prefix):
|
||||
if not module.startswith(_ext_base_pkg_idname_with_dot):
|
||||
continue
|
||||
module_id, submodule_id = module[len(module_prefix):].partition(".")[0::2]
|
||||
module_id, submodule_id = module[len(_ext_base_pkg_idname_with_dot):].partition(".")[0::2]
|
||||
try:
|
||||
addon_userdef_info[module_id][submodule_id] = addon
|
||||
except KeyError:
|
||||
|
||||
Reference in New Issue
Block a user