Add support for disabling modules and add CustomCommandsMenu and TestPlugin to it
This commit is contained in:
parent
8c117ff6e9
commit
68ade515eb
@ -73,6 +73,7 @@ DEFAULTS = {
|
||||
'hide_tabbar' : False,
|
||||
'scroll_tabbar' : False,
|
||||
'try_posix_regexp' : platform.system() != 'Linux',
|
||||
'disabled_plugins' : ['TestPlugin', 'CustomCommandsMenu'],
|
||||
},
|
||||
'keybindings': {
|
||||
'zoom_in' : '<Ctrl>plus',
|
||||
|
@ -10,7 +10,7 @@
|
||||
>>> registry = PluginRegistry()
|
||||
>>> registry.instances
|
||||
{}
|
||||
>>> registry.load_plugins()
|
||||
>>> registry.load_plugins(True)
|
||||
>>> plugins = registry.get_plugins_by_capability('test')
|
||||
>>> len(plugins)
|
||||
1
|
||||
@ -26,6 +26,7 @@
|
||||
import sys
|
||||
import os
|
||||
import borg
|
||||
from config import Config
|
||||
from util import dbg, err, get_config_dir
|
||||
|
||||
class Plugin(object):
|
||||
@ -61,12 +62,14 @@ class PluginRegistry(borg.Borg):
|
||||
if not self.done:
|
||||
self.done = False
|
||||
|
||||
def load_plugins(self):
|
||||
def load_plugins(self, testing=False):
|
||||
"""Load all plugins present in the plugins/ directory in our module"""
|
||||
if self.done:
|
||||
dbg('PluginRegistry::load_plugins: Already loaded')
|
||||
return
|
||||
|
||||
config = Config()
|
||||
|
||||
for plugindir in self.path:
|
||||
sys.path.insert(0, plugindir)
|
||||
try:
|
||||
@ -82,6 +85,8 @@ class PluginRegistry(borg.Borg):
|
||||
try:
|
||||
module = __import__(plugin[:-3], None, None, [''])
|
||||
for item in getattr(module, 'available'):
|
||||
if not testing and item in config['disabled_plugins']:
|
||||
continue
|
||||
if item not in self.instances:
|
||||
func = getattr(module, item)
|
||||
self.instances[item] = func()
|
||||
|
Loading…
Reference in New Issue
Block a user