1 # Copyright (C) 2006 by Aiwota Programmer
2 # aiwotaprog@tetteke.tk
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 from board_plugin_base import BoardPluginBase
27 base_path = os.path.join(config.get_config_dir_path(), "scripts")
30 def generate_board_plugin():
32 for module_path in glob(os.path.join(base_path, "board_*.py")):
33 module_name, ext = os.path.splitext(os.path.basename(module_path))
36 file, filename, description = imp.find_module(
37 module_name, [base_path])
38 module = imp.load_module(
39 module_name, file, filename, description)
48 def check_compatible(plugin_version):
49 if version[0] > plugin_version[0]:
51 elif version[0] < plugin_version[0]:
54 return version[1] <= plugin_version[1]
56 def load_plugin(plugin_module, widget_tree):
58 if check_compatible(plugin_module.version):
59 klass = plugin_module.BoardPlugin
60 if issubclass(klass, BoardPluginBase):
63 print klass, "is not subclass of BoardPluginBase"
65 print plugin_module.__file__, "not compatible", \
70 def load(widget_tree):
71 for i in itertools.imap(lambda e: load_plugin(e, widget_tree),
72 generate_board_plugin()): -1