1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2021 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 (emprunte a HappyDoc)
24 from __future__ import absolute_import
25 import glob,os,sys,traceback
27 from UserDict import UserDict
29 from collections import UserDict
32 class PluginLoader(UserDict):
33 def __init__(self,module):
34 UserDict.__init__(self)
35 self.plugin_dir=module.__path__[0]
36 self.plugin_setName=module.__name__
37 _module_list = glob.glob( os.path.join( self.plugin_dir,
38 '%s*py' % self.plugin_setName,
43 for _module_name in _module_list:
45 _module_name = os.path.basename(_module_name)[:-3]
46 _import_name = '%s.%s' % ( self.plugin_setName,
50 _module = __import__( _import_name )
52 sys.stderr.write('\n--- Plugin Module Error ---\n')
54 sys.stderr.write('---------------------------\n\n')
57 _module = getattr(_module, _module_name)
58 except AttributeError:
59 sys.stderr.write('ERROR: Could not retrieve %s\n' % _import_name)
62 info = _module.entryPoint()
63 except AttributeError:
66 self.addEntryPoint(info)
69 def addEntryPoint(self,infoDict):
71 factory=infoDict['factory']