diff options
author | Adam Tauber <asciimoo@gmail.com> | 2015-03-14 20:22:26 +0100 |
---|---|---|
committer | Adam Tauber <asciimoo@gmail.com> | 2015-03-14 20:22:26 +0100 |
commit | bf5d6f56c66feb3cac760f0f30cf4585a2e6134e (patch) | |
tree | 71bf54852f47602270270543d668ad81fe28dd06 /searx/plugins | |
parent | f7c18a04ac9d21691f9035ae0ee5e1b0e82dc33e (diff) | |
download | searxng-bf5d6f56c66feb3cac760f0f30cf4585a2e6134e.tar.gz searxng-bf5d6f56c66feb3cac760f0f30cf4585a2e6134e.zip |
[enh] plugin attribute type check
Diffstat (limited to 'searx/plugins')
-rw-r--r-- | searx/plugins/__init__.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/searx/plugins/__init__.py b/searx/plugins/__init__.py index 61ec211e4..1cc232560 100644 --- a/searx/plugins/__init__.py +++ b/searx/plugins/__init__.py @@ -4,14 +4,15 @@ from sys import exit logger = logger.getChild('plugins') -required_attrs = ('name', - 'description', - 'default_on') +required_attrs = (('name', str), + ('description', str), + ('default_on', bool)) class Plugin(): default_on = False name = 'Default plugin' + description = 'Default plugin description' class PluginStore(): @@ -25,8 +26,8 @@ class PluginStore(): def register(self, *plugins): for plugin in plugins: - for plugin_attr in required_attrs: - if not hasattr(plugin, plugin_attr): + for plugin_attr, plugin_attr_type in required_attrs: + if not hasattr(plugin, plugin_attr) or not isinstance(getattr(plugin, plugin_attr), plugin_attr_type): logger.critical('missing attribute "{0}", cannot load plugin: {1}'.format(plugin_attr, plugin)) exit(3) plugin.id = plugin.name.replace(' ', '_') |