Example #1
0
def scan_file(file):

    fp = open(file, 'r')
    mbox = UnixMailbox(fp)

    #msg = email.message_from_file(fp)
    #print_header(msg)
    #msg = email.message_from_file(fp)
    #print_header(msg)
    #print "ok"
    #return

    i = 0

    for mail in mbox:
        i = i + 1
        fromh = mail.getheader("from")
        date = mail.getdate("date")
        mydate = '%4d/%2d/%2d' % (date[2], date[1], date[0])
        print i, mydate, fromh
Example #2
0
#!/usr/bin/env python2.4

from mailbox import UnixMailbox
from PyLucene import StandardAnalyzer, FSDirectory, IndexWriter
from email import EmailDoc

store = FSDirectory.getDirectory('chipy-index', True)
writer = IndexWriter(store, StandardAnalyzer(), True)

mailbox = UnixMailbox(open('chipy.mbox'))
while True:
    msg = mailbox.next()
    if msg == None: break
    writer.addDocument(EmailDoc(msg))

writer.close()
Example #3
0
 def openmailbox(self):
     fd = self.vfs.open(self.getselector(), "rt")
     return UnixMailbox(fd)
Example #4
0
 def prepare(self):
     self.rfile = self.vfs.open(self.getselector(), "rt")
     self.mbox = UnixMailbox(self.rfile)
     FolderHandler.prepare(self)