20
# import test_mod # Use this as a template. This plugin has the minimum
21
# necessary functions.
1
# This program is free software; you can redistribute it and/or modify
2
# it under the terms of the GNU General Public License as published by
3
# the Free Software Foundation; either version 2 of the License, or
4
# (at your option) any later version.
6
# This program is distributed in the hope that it will be useful,
7
# but WITHOUT ANY WARRANTY; without even the implied warranty of
8
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
# GNU General Public License for more details.
11
# You should have received a copy of the GNU General Public License
12
# along with this program; if not, write to the Free Software
13
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15
# Ouattara Oumar Aziz ( alias wattazoum ) <wattazoum@gmail.com>
21
import gettext.gettext as _
25
This should be the plugin master class. To make a plugin you should inherit of this class
30
Returns the name of the plugin
31
@return: the name of the plugin
34
raise Exception('This method is mandatory !')
38
This method should give a little documentation about the this plugin.
39
@return: The doc string
41
raise Exception("Help not implemented for this plugin")
45
Return the plugin widget to be added to the main window when the plugin is selected
48
raise Exception('This method is mandatory')
50
def execute(self, gladeFile, destinationDir):
52
This method should do the task of generating the source code from the glade file.
53
@param gladeFile: The glade file to generate th code from
54
@param destinationDir: The destination directory to generate the file in.
55
@raise Exception: An exception should be raised if anything went fine.
57
raise Exception('This method is mandatory')
63
# This should be a dictionary of plugins
68
Search for plugins into the plugin directory and load them.
69
@return : The plugins dictionary list {'name':class}. Look at Plugin to know how it's used
73
if self.__pluginList : return self.__pluginList
75
self.__pluginList = dict()
76
tmp = inspect.getabsfile(inspect.getmodule(self))
77
plugins_dir = os.path.dirname(tmp)
78
if os.path.isdir(plugins_dir):
79
if plugins_dir not in sys.path:
80
sys.path.append(plugins_dir)
82
for file in glob.glob('%s/*/*.py' % plugins_dir):
84
module_filename = os.path.basename(file)
85
module_name, _ = os.path.splitext(module_filename)
86
plugin = __import__(module_name, '', module_filename)
87
for symbol_name in dir(plugin):
88
symbol = getattr(plugin, symbol_name)
89
if inspect.isclass(symbol) and symbol != Plugin and \
90
issubclass(symbol, Plugin):
91
#symbol.enabled = symbol.name in plugin_names
92
self.__pluginList[symbol_name] = symbol
95
print(_("Could not import plugin %(plugin_name)s ! Cause : %(error_cause)s ") % {'plugin_name':file,'error_cause': str(e)})
97
return self.__pluginList