[Zope-Checkins] CVS: Zope2 - __init__.py:1.1.2.11
andreas@serenade.digicool.com
andreas@serenade.digicool.com
Wed, 30 May 2001 10:31:54 -0400
Update of /cvs-repository/Zope2/lib/python/Products/PluginIndexes/TextIndex/Splitter
In directory serenade:/tmp/cvs-serv21044/Products/PluginIndexes/TextIndex/Splitter
Modified Files:
Tag: ajung-dropin-registry
__init__.py
Log Message:
--- Updated File __init__.py in package Zope2 --
--- __init__.py 2001/05/29 15:54:23 1.1.2.10
+++ __init__.py 2001/05/30 14:31:54 1.1.2.11
@@ -1,49 +1,22 @@
-import os,sys,exceptions,imp,string
+import os,sys,exceptions
-
availableSplitters = (
("ZopeSplitter" , "Zope Default Splitter"),
("ISO_8859_1_Splitter" , "Werner Strobles ISO Splitter")
)
-
-splitterNames = [ x[0] for x in availableSplitters]
-
-
-def loadModule(name):
-
- path,filename = os.path.split(name)
-
- name,ext = os.path.splitext(filename)
- # HACK !!!!
- path = [ os.path.join(os.getcwd(),"lib","python",path)]
-
- fp,pathname,desc = imp.find_module(name,path)
- try:
- module = imp.load_module(filename,fp,pathname,desc)
- finally:
- if fp: fp.close()
+splitterNames = map(lambda x: x[0],availableSplitters)
- return module
-
-
def getSplitter(name=None):
if not name in splitterNames and name:
raise exceptions.RuntimeError, "No such splitter '%s'" % name
if not name: name = splitterNames[0]
-
- module = None
- name = "Products/PluginIndexes/TextIndex/Splitter/" + name
- module = loadModule(name)
-
- if module: return module.Splitter
- else: return None
-
+ if not vars().has_key(name):
+ exec( "from %s import Splitter as %s" % (name,name))
-# HACK !!!
+ return vars()[name]
+
-from ZopeSplitter import Splitter as Splitter
-