1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
21 # simple script to enable all addons, and disable
30 def reload_addons(do_reload=True, do_reverse=True):
31 modules = addon_utils.modules({})
32 modules.sort(key=lambda mod: mod.__name__)
33 addons = bpy.context.user_preferences.addons
36 for mod_name in list(addons.keys()):
37 addon_utils.disable(mod_name)
39 assert(bool(addons) == False)
41 # Run twice each time.
44 mod_name = mod.__name__
45 print("\tenabling:", mod_name)
46 addon_utils.enable(mod_name)
47 assert(mod_name in addons)
49 for mod in addon_utils.modules({}):
50 mod_name = mod.__name__
51 print("\tdisabling:", mod_name)
52 addon_utils.disable(mod_name)
53 assert(not (mod_name in addons))
57 imp.reload(sys.modules[mod_name])
60 # incase order matters when it shouldnt
65 reload_addons(do_reload=False, do_reverse=False)
66 reload_addons(do_reload=False, do_reverse=True)
67 reload_addons(do_reload=True, do_reverse=True)
70 if __name__ == "__main__":
72 # So a python error exits(1)