Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/modules/addon_utils.py
| Show First 20 Lines • Show All 248 Lines • ▼ Show 20 Lines | if loaded_state is Ellipsis: | ||||
| loaded_state = False | loaded_state = False | ||||
| if mod and getattr(mod, "__addon_persistent__", False): | if mod and getattr(mod, "__addon_persistent__", False): | ||||
| loaded_default = True | loaded_default = True | ||||
| return loaded_default, loaded_state | return loaded_default, loaded_state | ||||
| def is_addon_active(context, module_name: str) -> bool: | |||||
campbellbartonUnsubmitted Not Done Inline Actions
campbellbarton: - Convention for this module is not to use annotation as there is no way to validate them. | |||||
| """Returns whether an addon is loaded and enabled in the current workspace.""" | |||||
| addon_enabled_in_userprefs = check(module_name)[1] | |||||
campbellbartonUnsubmitted Not Done Inline ActionsSame for variable names enabled_in_prefs for eg is sufficient. campbellbarton: Same for variable names `enabled_in_prefs` for eg is sufficient. | |||||
| if addon_enabled_in_userprefs and context.workspace.use_filter_by_owner: | |||||
| addon_enabled_in_workspace = module_name in context.workspace.owner_ids | |||||
| return addon_enabled_in_workspace | |||||
| return addon_enabled_in_userprefs | |||||
| # utility functions | # utility functions | ||||
| def _addon_ensure(module_name): | def _addon_ensure(module_name): | ||||
| addons = _preferences.addons | addons = _preferences.addons | ||||
| addon = addons.get(module_name) | addon = addons.get(module_name) | ||||
| if not addon: | if not addon: | ||||
| addon = addons.new() | addon = addons.new() | ||||
| ▲ Show 20 Lines • Show All 293 Lines • Show Last 20 Lines | |||||