1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library 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 GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 Ce module contient le chargeur dynamique de plugins (emprunté à HappyDoc)
24 import glob,os,sys,traceback
27 class PluginLoader(UserDict.UserDict):
28 def __init__(self,module):
29 UserDict.UserDict.__init__(self)
30 self.plugin_dir=module.__path__[0]
31 self.plugin_set_name=module.__name__
32 _module_list = glob.glob( os.path.join( self.plugin_dir,
33 '%s*py' % self.plugin_set_name,
38 for _module_name in _module_list:
40 _module_name = os.path.basename(_module_name)[:-3]
41 _import_name = '%s.%s' % ( self.plugin_set_name,
45 _module = __import__( _import_name )
47 sys.stderr.write('\n--- Plugin Module Error ---\n')
49 sys.stderr.write('---------------------------\n\n')
52 _module = getattr(_module, _module_name)
53 except AttributeError:
54 sys.stderr.write('ERROR: Could not retrieve %s\n' % _import_name)
57 info = _module.entryPoint()
58 except AttributeError:
61 self.addEntryPoint(info)
64 def addEntryPoint(self,infoDict):
66 factory=infoDict['factory']