[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/TextIndexNG - BaseConverter.py:1.1.2.5
Andreas Jung
andreas@digicool.com
Wed, 20 Mar 2002 18:15:56 -0500
Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/TextIndexNG
In directory cvs.zope.org:/tmp/cvs-serv14765
Modified Files:
Tag: ajung-textindexng-branch
BaseConverter.py
Log Message:
Moved more logic into Converter base class to make converters more smart
=== Zope/lib/python/Products/PluginIndexes/TextIndexNG/BaseConverter.py 1.1.2.4 => 1.1.2.5 ===
__version__ = '$Id$'
-import os
+import os, tempfile
+
+class TmpFile:
+
+ def __init__(self, data):
+ self.fname = tempfile.mktemp()
+ open(self.fname,'w').write(data)
+
+ def __str__(self): return self.fname
+ __repr__ = __str__
+
+ def __del__(self):
+ os.unlink(self.fname)
+
class BaseConverter:
""" Base class for all converters """
@@ -33,6 +46,10 @@
def execute(self,com):
text = os.popen( com ).read()
return text
+
+ def saveFile(self, data):
+ return TmpFile(data)
+
def getDescription(self): return self.content_description
def getType(self): return self.content_type