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


Groups > comp.lang.python > #7292

Iterating into maildir or mbox

From TheSaint <nobody@nowhere.net.no>
Newsgroups comp.lang.python
Subject Iterating into maildir or mbox
Followup-To comp.lang.python
Date 2011-06-09 19:55 +0800
Organization Aioe.org NNTP Server
Message-ID <isqcau$4qv$1@speranza.aioe.org> (permalink)

Followups directed to: comp.lang.python

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web