Update of /cvsroot/happydoc/HappyDoc/happydoclib
In directory usw-pr-cvs1:/tmp/cvs-serv24659
Modified Files:
pluginloader.py
Log Message:
Implemented feature #514237: Changed module lookups in pluginloader to
not require .py extension. This should allow plugins to be written in
any language for which Python can load a module, and as long as the
file is named with the right convention they will be picked up and
loaded. (The source of this change request was the maintainers of the
PLD Linux Distribution.)
Index: pluginloader.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc/happydoclib/pluginloader.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pluginloader.py 18 Nov 2001 23:14:57 -0000 1.2
--- pluginloader.py 7 Feb 2002 14:26:44 -0000 1.3
***************
*** 134,141 ****
# List of plugins
#
! _module_list = glob.glob( happydoclib.path.join( self.plugin_dir,
! '%s*py' % self.plugin_set_name,
! )
! )
_module_list.sort()
#
--- 134,138 ----
# List of plugins
#
! _module_list = self.getModuleList()
_module_list.sort()
#
***************
*** 147,151 ****
)
module_name_parts = _module_name.split(os.sep)
! module_base_name = module_name_parts[-1][:-3]
plugin_set_name = module_name_parts[-2]
if plugin_set_name != self.plugin_set_name:
--- 144,148 ----
)
module_name_parts = _module_name.split(os.sep)
! module_base_name = module_name_parts[-1]
plugin_set_name = module_name_parts[-2]
if plugin_set_name != self.plugin_set_name:
***************
*** 155,159 ****
TRACE.writeVar(parent_package_name=parent_package_name)
! _module_name = happydoclib.path.basename(_module_name)[:-3]
if self.parent_module_prefix:
_import_name = '%s.%s.%s' % (self.parent_module_prefix,
--- 152,156 ----
TRACE.writeVar(parent_package_name=parent_package_name)
! _module_name = happydoclib.path.basename(_module_name)
if self.parent_module_prefix:
_import_name = '%s.%s.%s' % (self.parent_module_prefix,
***************
*** 204,207 ****
--- 201,217 ----
return
+ def getModuleList(self):
+ "Return a list of module names to be used as plugins."
+ glob_pattern = happydoclib.path.join( self.plugin_dir,
+ '%s_*' % self.plugin_set_name,
+ )
+ all_files = glob.glob(glob_pattern)
+ all_basenames = [ os.path.splitext(x)[0] for x in all_files]
+ unique_modules = []
+ for module in all_basenames:
+ if module not in unique_modules:
+ unique_modules.append(module)
+ return unique_modules
+
def addEntryPoint(self, infoDict):
"""Add an entry point into a module to our lookup tables.
|