[Bf-blender-cvs] [848bc7c790e] temp-workspace-addons: Merge branch 'blender2.8' into temp-workspace-addons
Campbell Barton
noreply at git.blender.org
Thu Feb 1 04:23:26 CET 2018
Commit: 848bc7c790ec539d09f7804b51c7cf3622fde79e
Author: Campbell Barton
Date: Thu Feb 1 14:24:52 2018 +1100
Branches: temp-workspace-addons
https://developer.blender.org/rB848bc7c790ec539d09f7804b51c7cf3622fde79e
Merge branch 'blender2.8' into temp-workspace-addons
===================================================================
===================================================================
diff --cc release/scripts/modules/addon_utils.py
index 7a00d841e74,97fc45189f2..224323cb520
--- a/release/scripts/modules/addon_utils.py
+++ b/release/scripts/modules/addon_utils.py
@@@ -43,8 -43,8 +43,8 @@@ def _initialize(*, addon_collection)
path_list = paths()
for path in path_list:
_bpy.utils._sys_path_ensure(path)
- for addon in _user_preferences.addons:
- enable(addon.module)
+ for addon in addon_collection:
- enable(addon_collection, addon.module)
++ enable(addon.module, addon_collection=addon_collection)
def paths():
@@@ -217,7 -212,7 +220,7 @@@ def modules(*, addon_collection, module
modules._is_first = True
- def check(addon_collection, module_name):
-def check(module_name):
++def check(module_name, *, addon_collection):
"""
Returns the loaded state of the addon.
@@@ -227,11 -222,13 +230,13 @@@
:rtype: tuple of booleans
"""
import sys
- loaded_default = module_name in _user_preferences.addons
+ loaded_default = module_name in addon_collection
mod = sys.modules.get(module_name)
- loaded_state = ((mod is not None) and
- getattr(mod, "__addon_enabled__", Ellipsis))
+ loaded_state = (
+ (mod is not None) and
+ getattr(mod, "__addon_enabled__", Ellipsis)
+ )
if loaded_state is Ellipsis:
print("Warning: addon-module %r found module "
@@@ -249,21 -246,24 +254,21 @@@
# utility functions
- def _addon_ensure(addon_collection, module_name):
-def _addon_ensure(module_name):
- addons = _user_preferences.addons
- addon = addons.get(module_name)
++def _addon_ensure(module_name, *, addon_collection):
+ addon = addon_collection.get(module_name)
if not addon:
- addon = addons.new()
+ addon = addon_collection.new()
addon.module = module_name
- def _addon_remove(addon_collection, module_name):
-def _addon_remove(module_name):
- addons = _user_preferences.addons
-
- while module_name in addons:
- addon = addons.get(module_name)
++def _addon_remove(module_name, *, addon_collection):
+ while module_name in addon_collection:
+ addon = addon_collection.get(module_name)
if addon:
- addons.remove(addon)
+ addon_collection.remove(addon)
- def enable(addon_collection, module_name, *, default_set=False, persistent=False, handle_error=None):
-def enable(module_name, *, default_set=False, persistent=False, handle_error=None):
++def enable(module_name, *, addon_collection, default_set=False, persistent=False, handle_error=None):
"""
Enables an addon by name.
@@@ -324,7 -324,7 +329,7 @@@
# add the addon first it may want to initialize its own preferences.
# must remove on fail through.
if default_set:
- _addon_ensure(addon_collection, module_name)
- _addon_ensure(module_name)
++ _addon_ensure(module_name, addon_collection=addon_collection)
# Split registering up into 3 steps so we can undo
# if it fails par way through.
@@@ -346,7 -346,7 +351,7 @@@
handle_error(ex)
if default_set:
- _addon_remove(addon_collection, module_name)
- _addon_remove(module_name)
++ _addon_remove(module_name, addon_collection=addon_collection)
return None
# 2) try register collected modules
@@@ -361,7 -361,7 +366,7 @@@
handle_error(ex)
del sys.modules[module_name]
if default_set:
- _addon_remove(addon_collection, module_name)
- _addon_remove(module_name)
++ _addon_remove(module_name, addon_collection=addon_collection)
return None
# * OK loaded successfully! *
@@@ -413,7 -413,7 +418,7 @@@ def disable(module_name, *, addon_colle
# could be in more than once, unlikely but better do this just in case.
if default_set:
- _addon_remove(addon_collection, module_name)
- _addon_remove(module_name)
++ _addon_remove(module_name, addon_collection=addon_collection)
if _bpy.app.debug_python:
print("\taddon_utils.disable", module_name)
diff --cc release/scripts/startup/bl_operators/wm.py
index 45194ae7bff,cf07152d979..38ae1899dbf
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@@ -1830,9 -1833,7 +1833,14 @@@ class WM_OT_addon_enable(Operator)
err_str = traceback.format_exc()
print(err_str)
- mod = addon_utils.enable(self.module, default_set=True, handle_error=err_cb)
+ addon_collection = addon_utils.addon_collection_from_context(context)
+
- mod = addon_utils.enable(addon_collection, self.module, default_set=True, handle_error=err_cb)
++ mod = addon_utils.enable(
++ self.module,
++ addon_collection=addon_collection,
++ default_set=True,
++ handle_error=err_cb,
++ )
if mod:
info = addon_utils.module_bl_info(mod)
diff --cc release/scripts/startup/bl_ui/__init__.py
index fbed3383a9e,79d044c25bf..032855a7b0e
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@@ -114,13 -117,13 +117,14 @@@ def register()
def addon_filter_items(self, context):
import addon_utils
+ addon_collection = addon_utils.addon_collection_from_context(context)
- items = [('All', "All", "All Add-ons"),
- ('User', "User", "All Add-ons Installed by User"),
- ('Enabled', "Enabled", "All Enabled Add-ons"),
- ('Disabled', "Disabled", "All Disabled Add-ons"),
- ]
+ items = [
+ ('All', "All", "All Add-ons"),
+ ('User', "User", "All Add-ons Installed by User"),
+ ('Enabled', "Enabled", "All Enabled Add-ons"),
+ ('Disabled', "Disabled", "All Disabled Add-ons"),
+ ]
items_unique = set()
More information about the Bf-blender-cvs
mailing list