[Tess-developers] TheSpamSecretary TheSpamSecretary.py,1.10,1.11
Brought to you by:
kwerle
|
From: <kw...@us...> - 2003-01-13 00:15:53
|
Update of /cvsroot/tess/TheSpamSecretary
In directory sc8-pr-cvs1:/tmp/cvs-serv26414
Modified Files:
TheSpamSecretary.py
Log Message:
Decode messages that are not multipart, but are base64 encoded.
Index: TheSpamSecretary.py
===================================================================
RCS file: /cvsroot/tess/TheSpamSecretary/TheSpamSecretary.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** TheSpamSecretary.py 7 Jan 2003 04:55:19 -0000 1.10
--- TheSpamSecretary.py 13 Jan 2003 00:15:49 -0000 1.11
***************
*** 36,40 ****
import getopt
import ConfigParser
! import cPickle
import anydbm
import fcntl
--- 36,40 ----
import getopt
import ConfigParser
! #import cPickle
import anydbm
import fcntl
***************
*** 466,498 ****
outputData = StringIO.StringIO()
outputData.write(aMessage)
#deal with mime messages
#this should take care of most non-english messages, too
! if (re.match("multipart", aMessage.gettype())):
! #print(aMessage.gettype())
! multiFile = multifile.MultiFile(someFile)
! multiFile.push(aMessage.getparam("boundary"))
! while multiFile.next():
! onePart = mimetools.Message(multiFile)
! #print("TYPE: %s" % onePart.gettype())
! if (not (re.search("application", onePart.gettype()) or re.search("image", onePart.gettype()))):
! try:
! mimetools.decode(multiFile, outputData, onePart.getencoding())
! except:
! self.logFile.write("Failed to decode something of type %s\n" % onePart.getencoding())
! #else:
! # print("NO DECODE")
! #print(outputData.getvalue())
! self.addTokensFromTextToDict(outputData.getvalue(), self.tempDict)
else:
! self.addTokensFromTextToDict(outputData.getvalue(), self.tempDict)
! while (1):
! lastPosition = someFile.tell()
! oneLine = someFile.readline()
! if ((oneLine == '') or (self.fromLine.match(oneLine))):
! #if (aMessage.islast(oneLine)):
! someFile.seek(lastPosition)
! break
! self.addTokensFromTextToDict(oneLine, self.tempDict)
! #print("oneline: %s" % oneLine)
return(count)
--- 466,513 ----
outputData = StringIO.StringIO()
outputData.write(aMessage)
+ #print("MS:%s:ME" % outputData.getvalue())
#deal with mime messages
#this should take care of most non-english messages, too
! if (re.match("base64", aMessage.getencoding())):
! if (re.match("text", aMessage.getmaintype())):
! #sys.stderr.write("%s\n" % aMessage.getencoding())
! #sys.stderr.write("%s\n" % aMessage.getmaintype()) # "text"
! try:
! mimetools.decode(someFile, outputData, "base64")
! except:
! self.logFile.write("Failed to decode something of type %s\n" % aMessage.getmaintype())
! #print("MSXXX:%s:MEXXX" % outputData.getvalue())
! self.addTokensFromTextToDict(outputData.getvalue(), self.tempDict)
! #print(aMessage.get_payload(None, 1))
! else:
! self.logFile.write("Not decoding something of type %s\n" % aMessage.getmaintype())
else:
! if (re.match("multipart", aMessage.gettype())):
! #print(aMessage.gettype())
! multiFile = multifile.MultiFile(someFile)
! multiFile.push(aMessage.getparam("boundary"))
! while multiFile.next():
! onePart = mimetools.Message(multiFile)
! #print("TYPE: %s" % onePart.gettype())
! if (not (re.search("application", onePart.gettype()) or re.search("image", onePart.gettype()))):
! try:
! mimetools.decode(multiFile, outputData, onePart.getencoding())
! except:#
! self.logFile.write("Failed to decode something of type %s\n" % onePart.getencoding())
! #else:
! # print("NO DECODE")
! #print(outputData.getvalue())
! self.addTokensFromTextToDict(outputData.getvalue(), self.tempDict)
! else:
! self.addTokensFromTextToDict(outputData.getvalue(), self.tempDict)
! while (1):
! lastPosition = someFile.tell()
! oneLine = someFile.readline()
! if ((oneLine == '') or (self.fromLine.match(oneLine))):
! #if (aMessage.islast(oneLine)):
! someFile.seek(lastPosition)
! break
! self.addTokensFromTextToDict(oneLine, self.tempDict)
! #print("oneline: %s" % oneLine)
return(count)
|