diff --git a/scripts/modules/addon_utils.py b/scripts/modules/addon_utils.py index d64f85efe49..77f8fc70afb 100644 --- a/scripts/modules/addon_utils.py +++ b/scripts/modules/addon_utils.py @@ -628,36 +628,36 @@ def _fake_module_from_extension(mod_name, mod_path, force_support=None): bl_info = _bl_info_basis() - filepath = os.path.join(os.path.dirname(mod_path), _ext_manifest_filename_toml) + filepath_toml = os.path.join(os.path.dirname(mod_path), _ext_manifest_filename_toml) try: - with open(filepath, "rb") as fh: + with open(filepath_toml, "rb") as fh: data = tomllib.load(fh) except BaseException as ex: - print("Error:", str(ex), "in", filepath) + print("Error:", str(ex), "in", filepath_toml) return None # This isn't a full validation which happens on package install/update. if (value := data.get("name", None)) is None: - print("Error: missing \"name\" from in", filepath) + print("Error: missing \"name\" from in", filepath_toml) return None if type(value) is not str: - print("Error: \"name\" is not a string in", filepath) + print("Error: \"name\" is not a string in", filepath_toml) return None bl_info["name"] = value if (value := data.get("version", None)) is None: - print("Error: missing \"version\" from in", filepath) + print("Error: missing \"version\" from in", filepath_toml) return None if type(value) is not str: - print("Error: \"version\" is not a string in", filepath) + print("Error: \"version\" is not a string in", filepath_toml) return None bl_info["version"] = value if (value := data.get("author", None)) is None: - print("Error: missing \"author\" from in", filepath) + print("Error: missing \"author\" from in", filepath_toml) return None if (type(value) is not list) or any(x for x in value if type(x) is not str): - print("Error: \"author\" is not a list of strings in", filepath) + print("Error: \"author\" is not a list of strings in", filepath_toml) return None bl_info["author"] = ", ".join(value) diff --git a/scripts/modules/bl_i18n_utils/bl_extract_messages.py b/scripts/modules/bl_i18n_utils/bl_extract_messages.py index bd3fc0d53b4..f7c44f54aa0 100644 --- a/scripts/modules/bl_i18n_utils/bl_extract_messages.py +++ b/scripts/modules/bl_i18n_utils/bl_extract_messages.py @@ -1100,14 +1100,14 @@ def dump_messages(do_messages, do_checks, settings): return pot # Not used currently, but may be useful later (and to be consistent with dump_addon_messages!). -def dump_addon_messages(module_name, do_checks, settings): +def dump_addon_messages(addon_module_name, do_checks, settings): import addon_utils # Get current addon state (loaded or not): - was_loaded = addon_utils.check(module_name)[1] + was_loaded = addon_utils.check(addon_module_name)[1] # Enable our addon. - addon = utils.enable_addons(addons={module_name})[0] + addon = utils.enable_addons(addons={addon_module_name})[0] addon_info = addon_utils.module_bl_info(addon) ver = addon_info["name"] + " " + ".".join(str(v) for v in addon_info["version"]) @@ -1131,7 +1131,7 @@ def dump_addon_messages(module_name, do_checks, settings): print("C") # Now disable our addon, and re-scan RNA. - utils.enable_addons(addons={module_name}, disable=True) + utils.enable_addons(addons={addon_module_name}, disable=True) print("D") reports["check_ctxt"] = minus_check_ctxt print("E") @@ -1140,7 +1140,7 @@ def dump_addon_messages(module_name, do_checks, settings): # Restore previous state if needed! if was_loaded: - utils.enable_addons(addons={module_name}) + utils.enable_addons(addons={addon_module_name}) # and make the diff! for key in minus_msgs: diff --git a/scripts/modules/bl_i18n_utils/utils.py b/scripts/modules/bl_i18n_utils/utils.py index 7e90f4573f4..a4da39cdb56 100644 --- a/scripts/modules/bl_i18n_utils/utils.py +++ b/scripts/modules/bl_i18n_utils/utils.py @@ -212,7 +212,7 @@ def enable_addons(addons=None, support=None, disable=False, check_only=False): support = {} prefs = bpy.context.preferences - used_ext = {ext.module for ext in prefs.addons} + used_addon_module_names = {addon.module for addon in prefs.addons} # In case we need to blacklist some add-ons... black_list = {} @@ -226,17 +226,17 @@ def enable_addons(addons=None, support=None, disable=False, check_only=False): if not check_only: for mod in ret: try: - module_name = mod.__name__ + addon_module_name = mod.__name__ if disable: - if module_name not in used_ext: + if addon_module_name not in used_addon_module_names: continue - print(" Disabling module ", module_name) - bpy.ops.preferences.addon_disable(module=module_name) + print(" Disabling module ", addon_module_name) + bpy.ops.preferences.addon_disable(module=addon_module_name) else: - if module_name in used_ext: + if addon_module_name in used_addon_module_names: continue - print(" Enabling module ", module_name) - bpy.ops.preferences.addon_enable(module=module_name) + print(" Enabling module ", addon_module_name) + bpy.ops.preferences.addon_enable(module=addon_module_name) except BaseException as ex: # XXX TEMP WORKAROUND print(ex) diff --git a/scripts/modules/bpy/utils/__init__.py b/scripts/modules/bpy/utils/__init__.py index e0b2d9f5783..a8ba8ad6de8 100644 --- a/scripts/modules/bpy/utils/__init__.py +++ b/scripts/modules/bpy/utils/__init__.py @@ -219,8 +219,8 @@ def load_scripts(*, reload_scripts=False, refresh_scripts=False, extensions=True # to reload. note that they will only actually reload of the # modification time changes. This `won't` work for packages so... # its not perfect. - for module_name in [ext.module for ext in _preferences.addons]: - _addon_utils.disable(module_name) + for addon_module_name in [ext.module for ext in _preferences.addons]: + _addon_utils.disable(addon_module_name) def register_module_call(mod): register = getattr(mod, "register", None) diff --git a/scripts/startup/bl_operators/userpref.py b/scripts/startup/bl_operators/userpref.py index b6a22fd3772..60f096a99cb 100644 --- a/scripts/startup/bl_operators/userpref.py +++ b/scripts/startup/bl_operators/userpref.py @@ -448,9 +448,9 @@ class PREFERENCES_OT_addon_enable(Operator): mod = addon_utils.enable(self.module, default_set=True, handle_error=err_cb) if mod: - info = addon_utils.module_bl_info(mod) + bl_info = addon_utils.module_bl_info(mod) - info_ver = info.get("blender", (0, 0, 0)) + info_ver = bl_info.get("blender", (0, 0, 0)) if info_ver > bpy.app.version: self.report( @@ -725,12 +725,12 @@ class PREFERENCES_OT_addon_install(Operator): # but for now just use the first for mod in addon_utils.modules(refresh=False): if mod.__name__ in addons_new: - info = addon_utils.module_bl_info(mod) + bl_info = addon_utils.module_bl_info(mod) # show the newly installed addon. context.preferences.view.show_addons_enabled_only = False context.window_manager.addon_filter = 'All' - context.window_manager.addon_search = info["name"] + context.window_manager.addon_search = bl_info["name"] break # in case a new module path was created to install this addon. @@ -825,12 +825,12 @@ class PREFERENCES_OT_addon_expand(Operator): def execute(self, _context): import addon_utils - module_name = self.module + addon_module_name = self.module - mod = addon_utils.addons_fake_modules.get(module_name) + mod = addon_utils.addons_fake_modules.get(addon_module_name) if mod is not None: - info = addon_utils.module_bl_info(mod) - info["show_expanded"] = not info["show_expanded"] + bl_info = addon_utils.module_bl_info(mod) + bl_info["show_expanded"] = not bl_info["show_expanded"] return {'FINISHED'} @@ -849,18 +849,18 @@ class PREFERENCES_OT_addon_show(Operator): def execute(self, context): import addon_utils - module_name = self.module + addon_module_name = self.module _modules = addon_utils.modules(refresh=False) - mod = addon_utils.addons_fake_modules.get(module_name) + mod = addon_utils.addons_fake_modules.get(addon_module_name) if mod is not None: - info = addon_utils.module_bl_info(mod) - info["show_expanded"] = True + bl_info = addon_utils.module_bl_info(mod) + bl_info["show_expanded"] = True context.preferences.active_section = 'ADDONS' context.preferences.view.show_addons_enabled_only = False context.window_manager.addon_filter = 'All' - context.window_manager.addon_search = info["name"] + context.window_manager.addon_search = bl_info["name"] bpy.ops.screen.userpref_show('INVOKE_DEFAULT') return {'FINISHED'} diff --git a/scripts/startup/bl_ui/__init__.py b/scripts/startup/bl_ui/__init__.py index 78959c551d1..c27739e3f5a 100644 --- a/scripts/startup/bl_ui/__init__.py +++ b/scripts/startup/bl_ui/__init__.py @@ -142,8 +142,8 @@ def register(): items_unique = set() for mod in addon_utils.modules(refresh=False): - info = addon_utils.module_bl_info(mod) - items_unique.add(info["category"]) + bl_info = addon_utils.module_bl_info(mod) + items_unique.add(bl_info["category"]) items.extend([(cat, cat, "") for cat in sorted(items_unique)]) return items diff --git a/scripts/startup/bl_ui/properties_workspace.py b/scripts/startup/bl_ui/properties_workspace.py index b0ea251031a..c9d76f75866 100644 --- a/scripts/startup/bl_ui/properties_workspace.py +++ b/scripts/startup/bl_ui/properties_workspace.py @@ -75,15 +75,15 @@ class WORKSPACE_PT_addons(WorkSpaceButtonsPanel, Panel): if unknown_addons: layout.label(text="Unknown add-ons", icon='ERROR') col = layout.box().column(align=True) - for module_name in sorted(unknown_addons): + for addon_module_name in sorted(unknown_addons): row = col.row() row.alignment = 'LEFT' row.operator( "wm.owner_disable", icon='CHECKBOX_HLT', - text=module_name, + text=addon_module_name, emboss=False, - ).owner_id = module_name + ).owner_id = addon_module_name class WORKSPACE_UL_addons_items(UIList): @@ -95,8 +95,8 @@ class WORKSPACE_UL_addons_items(UIList): module = WORKSPACE_PT_addons.addon_map.get(addon.module) if not module: return addon.module - info = addon_utils.module_bl_info(module) - return "%s: %s" % (iface_(info["category"]), iface_(info["name"])) + bl_info = addon_utils.module_bl_info(module) + return "%s: %s" % (iface_(bl_info["category"]), iface_(bl_info["name"])) @staticmethod def _filter_addons_by_category_name(pattern, bitflag, addons, reverse=False): diff --git a/scripts/startup/bl_ui/space_userpref.py b/scripts/startup/bl_ui/space_userpref.py index 2c3161b56b7..380466d7836 100644 --- a/scripts/startup/bl_ui/space_userpref.py +++ b/scripts/startup/bl_ui/space_userpref.py @@ -2243,18 +2243,18 @@ class USERPREF_PT_addons(AddOnPanel, Panel): # initialized on demand user_addon_paths = [] - for mod, info in addons: - module_name = mod.__name__ + for mod, bl_info in addons: + addon_module_name = mod.__name__ - is_enabled = module_name in used_addon_module_name_map + is_enabled = addon_module_name in used_addon_module_name_map - if info["support"] not in support: + if bl_info["support"] not in support: continue # check if addon should be visible with current filters is_visible = ( (filter == "All") or - (filter == info["category"]) or + (filter == bl_info["category"]) or (filter == "User" and (mod.__file__.startswith(addon_user_dirs))) ) if show_enabled_only: @@ -2264,11 +2264,11 @@ class USERPREF_PT_addons(AddOnPanel, Panel): continue if search and not ( - (search in info["name"].lower() or - search in iface_(info["name"]).lower()) or - (info["author"] and (search in info["author"].lower())) or - ((filter == "All") and (search in info["category"].lower() or - search in iface_(info["category"]).lower())) + (search in bl_info["name"].lower() or + search in iface_(bl_info["name"]).lower()) or + (bl_info["author"] and (search in bl_info["author"].lower())) or + ((filter == "All") and (search in bl_info["category"].lower() or + search in iface_(bl_info["category"]).lower())) ): continue @@ -2278,37 +2278,37 @@ class USERPREF_PT_addons(AddOnPanel, Panel): colsub = box.column() row = colsub.row(align=True) - is_extension = addon_utils.check_extension(module_name) + is_extension = addon_utils.check_extension(addon_module_name) row.operator( "preferences.addon_expand", - icon='DISCLOSURE_TRI_DOWN' if info["show_expanded"] else 'DISCLOSURE_TRI_RIGHT', + icon='DISCLOSURE_TRI_DOWN' if bl_info["show_expanded"] else 'DISCLOSURE_TRI_RIGHT', emboss=False, - ).module = module_name + ).module = addon_module_name row.operator( "preferences.addon_disable" if is_enabled else "preferences.addon_enable", icon='CHECKBOX_HLT' if is_enabled else 'CHECKBOX_DEHLT', text="", emboss=False, - ).module = module_name + ).module = addon_module_name sub = row.row() sub.active = is_enabled - sub.label(text="%s: %s" % (iface_(info["category"]), iface_(info["name"]))) + sub.label(text="%s: %s" % (iface_(bl_info["category"]), iface_(bl_info["name"]))) - if info["warning"]: + if bl_info["warning"]: sub.label(icon='ERROR') # icon showing support level. - sub.label(icon=self._support_icon_mapping.get(info["support"], 'QUESTION')) + sub.label(icon=self._support_icon_mapping.get(bl_info["support"], 'QUESTION')) - # Expanded UI (only if additional info is available) - if info["show_expanded"]: - if value := info["description"]: + # Expanded UI (only if additional bl_info is available) + if bl_info["show_expanded"]: + if value := bl_info["description"]: split = colsub.row().split(factor=0.15) split.label(text="Description:") split.label(text=iface_(value)) - if value := info["location"]: + if value := bl_info["location"]: split = colsub.row().split(factor=0.15) split.label(text="Location:") split.label(text=iface_(value)) @@ -2316,11 +2316,11 @@ class USERPREF_PT_addons(AddOnPanel, Panel): split = colsub.row().split(factor=0.15) split.label(text="File:") split.label(text=mod.__file__, translate=False) - if value := info["author"]: + if value := bl_info["author"]: split = colsub.row().split(factor=0.15) split.label(text="Author:") split.label(text=value, translate=False) - if value := info["version"]: + if value := bl_info["version"]: split = colsub.row().split(factor=0.15) split.label(text="Version:") # Extensions use SEMVER. @@ -2328,32 +2328,32 @@ class USERPREF_PT_addons(AddOnPanel, Panel): split.label(text=value, translate=False) else: split.label(text=".".join(str(x) for x in value), translate=False) - if value := info["warning"]: + if value := bl_info["warning"]: split = colsub.row().split(factor=0.15) split.label(text="Warning:") split.label(text=" " + iface_(value), icon='ERROR') del value user_addon = USERPREF_PT_addons.is_user_addon(mod, user_addon_paths) - if info["doc_url"] or info.get("tracker_url"): + if bl_info["doc_url"] or bl_info.get("tracker_url"): split = colsub.row().split(factor=0.15) split.label(text="Internet:") sub = split.row() - if info["doc_url"]: + if bl_info["doc_url"]: sub.operator( "wm.url_open", text="Documentation", icon='HELP', - ).url = info["doc_url"] + ).url = bl_info["doc_url"] # Only add "Report a Bug" button if tracker_url is set # or the add-on is bundled (use official tracker then). - if info.get("tracker_url"): + if bl_info.get("tracker_url"): sub.operator( "wm.url_open", text="Report a Bug", icon='URL', - ).url = info["tracker_url"] + ).url = bl_info["tracker_url"] elif not user_addon: addon_info = ( "Name: %s %s\n" "Author: %s\n" - ) % (info["name"], str(info["version"]), info["author"]) + ) % (bl_info["name"], str(bl_info["version"]), bl_info["author"]) props = sub.operator( "wm.url_open_preset", text="Report a Bug", icon='URL', ) @@ -2369,24 +2369,24 @@ class USERPREF_PT_addons(AddOnPanel, Panel): # Show addon user preferences if is_enabled: - if (addon_preferences := used_addon_module_name_map[module_name].preferences) is not None: + if (addon_preferences := used_addon_module_name_map[addon_module_name].preferences) is not None: self.draw_addon_preferences(col_box, context, addon_preferences) # Append missing scripts # First collect scripts that are used but have no script file. - module_names = {mod.__name__ for mod, info in addons} + module_names = {mod.__name__ for mod, bl_info in addons} missing_modules = { - module_name for module_name in used_addon_module_name_map - if module_name not in module_names + addon_module_name for addon_module_name in used_addon_module_name_map + if addon_module_name not in module_names } if missing_modules and filter in {"All", "Enabled"}: col.column().separator() col.column().label(text="Missing script files") - module_names = {mod.__name__ for mod, info in addons} - for module_name in sorted(missing_modules): - is_enabled = module_name in used_addon_module_name_map + module_names = {mod.__name__ for mod, bl_info in addons} + for addon_module_name in sorted(missing_modules): + is_enabled = addon_module_name in used_addon_module_name_map # Addon UI Code box = col.column().box() colsub = box.column() @@ -2397,9 +2397,9 @@ class USERPREF_PT_addons(AddOnPanel, Panel): if is_enabled: row.operator( "preferences.addon_disable", icon='CHECKBOX_HLT', text="", emboss=False, - ).module = module_name + ).module = addon_module_name - row.label(text=module_name, translate=False) + row.label(text=addon_module_name, translate=False) # -----------------------------------------------------------------------------