Iterating into maildir or mbox

Discussion in 'Python' started by TheSaint, Jun 9, 2011.

  1. TheSaint

    TheSaint Guest

    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
    TheSaint, Jun 9, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matej Cepl

    mailbox.py examples (Maildir)

    Matej Cepl, Aug 6, 2003, in forum: Python
    Replies:
    1
    Views:
    462
    David M. Cooke
    Aug 6, 2003
  2. matej
    Replies:
    0
    Views:
    350
    matej
    Jan 9, 2007
  3. Replies:
    0
    Views:
    398
  4. carl
    Replies:
    5
    Views:
    2,367
    James Kanze
    Nov 25, 2009
  5. Replies:
    3
    Views:
    561
    John Nagle
    Aug 27, 2010
Loading...

Share This Page