Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7292 > unrolled thread

Iterating into maildir or mbox

Started byTheSaint <nobody@nowhere.net.no>
First post2011-06-09 19:55 +0800
Last post2011-06-09 19:55 +0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Iterating into maildir or mbox TheSaint <nobody@nowhere.net.no> - 2011-06-09 19:55 +0800

#7292 — Iterating into maildir or mbox

FromTheSaint <nobody@nowhere.net.no>
Date2011-06-09 19:55 +0800
SubjectIterating into maildir or mbox
Message-ID<isqcau$4qv$1@speranza.aioe.org>
Hello,

originally with python 2.4 ~ 2.7 (I think) iterating a maildir I was using

++++++++++++++++++++++++++Code+++++++++++++++++++++++++++++++++
try:
    mbox= mailbox.PortableUnixMailbox(open(mbox,'r'))
except IOError:
    # if file not found default is None
    mbox= None
 while mbox:
     msg= next(mbox)
     if msg is None: break
     try:
         m= msg.getheader('message-id')
         if m: dx= m.strip('<>')
         else: continue
     except (IndexError, AttributeError, IOError):
         # message without ID, put some mark
         dx= str(time.time()).split('.')
         dx= int(dx[0])*int(dx[1])
         if dx in lmbox:continue
     lmbox[dx]= dx
 return lmbox
++++++++++++++++++++++++++Code+++++++++++++++++++++++++++++++++

I'm tryng to convert into Python 3.2, but I don't get why this is not 
iterable anymore.


-- 
goto /dev/null

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web