addon_utils: add disable_all function
authorCampbell Barton <ideasman42@gmail.com>
Thu, 23 Mar 2017 18:20:26 +0000 (05:20 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 23 Mar 2017 18:20:26 +0000 (05:20 +1100)
release/scripts/modules/addon_utils.py

index 886f078f046a8aee140b65779b040eeb0c629ced..51e3e65b78cc72143c475bfa8ea4dc1db3193bf9 100644 (file)
@@ -24,6 +24,7 @@ __all__ = (
     "check",
     "enable",
     "disable",
+    "disable_all",
     "reset_all",
     "module_bl_info",
 )
@@ -444,6 +445,13 @@ def reset_all(*, reload_scripts=False):
                 disable(mod_name)
 
 
+def disable_all():
+    import sys
+    for mod_name, mod in sys.modules.items():
+        if getattr(mod, "__addon_enabled__", False):
+            disable(mod_name)
+
+
 def module_bl_info(mod, info_basis=None):
     if info_basis is None:
         info_basis = {