[spambayes-dev] patch for splitndir.py

papaDoc papaDoc at videotron.ca
Thu Sep 25 10:06:03 EDT 2003


Hi,

This is a patch for splitndir.py

When splitting the mbox we check if the header mailid_header_name is 
present then
we give this name to the message file if not we set the name to be the 
counter number.

This was/(will be) useful for me to retrieve a message that generate a 
exception in pop3proxy but
the message was discarded in the cache directory. I will re split my 
inbox and copy all the file
in the cache directory to test which one caused the error.


Remi

P.S. The more I program in Python the more I like it ;-)


diff -C 3 splitndirs.py splitndirs.py.orig
*** splitndirs.py       Thu Sep 25 09:59:37 2003
--- splitndirs.py.orig  Thu Sep 25 09:58:58 2003
***************
*** 53,61 ****
  import glob

  from spambayes import mboxutils
- from spambayes.Options import options
-
- from email.Header import Header

  try:
      True, False
--- 53,58 ----
***************
*** 119,134 ****
                  astext = str(msg)
                  #assert astext.endswith('\n')
                  counter += 1
!                 try:
!                     mail_id = options["Headers", "mailid_header_name"]
!                     id_str =  msg.get(mail_id)
!                     if id_str is None:
!                         msgfile = open('%s/%d' % (outdirs[i], 
counter), 'wb')
!                     else:
!                         msgfile = open('%s/%s' % (outdirs[i], 
msg.get(mail_id
), 'wb')
!                 except:
!                     print "Counter = %d" % (counter)
!                     msgfile = open('%s/%d' % (outdirs[i], counter), 'wb')
                  msgfile.write(astext)
                  msgfile.close()
                  if verbose:
--- 116,122 ----
                  astext = str(msg)
                  #assert astext.endswith('\n')
                  counter += 1
!                 msgfile = open('%s/%d' % (outdirs[i], counter), 'wb')
                  msgfile.write(astext)
                  msgfile.close()
                  if verbose:




More information about the spambayes-dev mailing list