472,952 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,952 software developers and data experts.

mailbox module, Maildir, and flags

Dear all,

I'm trying to figure out if mailbox will let me get the flags of a
Maildir message without running get_message on it, and reading the
whole message. It seems like it should work by doing this:
>>import mailbox
mybox = mailbox.Maildir('~/Maildir/', mailbox.MaildirMessage)
myfolder = mybox.get_folder('School')
>>msg = myfolder.next()
But then,when I try to get_flags on msg, I get nothing

Instead, I have to ener
which reads the whole message. Then the flags show up (RS or
whatever). Given that there's 2102 messages in the folder, and some of
them have attachments, I'd rather run get_message on all of them.

To explain my motivation: I'm writing a curses email client as a
hobby. I started out with IMAP, and implemented a simple caching
behaviour, using a pickled cache. When it logs in to the IMAP server,
it checks only the uids and flags on the server, compares those to the
ones in the cache, and from that can figure out what has been added,
deleted, or changed. From that, it can figure out what headers to
download. Saves a *lot* of time at startup.

I'd like to implement something like this for Maildir. Figure out
which msgs it needs to get a new Message instance for, and only those.
The rest are in the cache. So after the first time, starting up on a
large maildir folder will be pretty quick. Following the same logic, I
just need the unique names and the flags. Now, I know the flags are in
the name, but I can't find anyway in the mailbox module to get them.

So, should I just run some text parsing on the filenames, using
os.listdir? Given:

'1110326951.M818715P9617V0000000000000307I001A45A4 _1401.belacqua,S=960:2,RS'

it's easy enough to apply string.split(":2,"). But then I have to deal
with all the nastiness of the maildir standard. This is probably what
I'll end up doing, but I was wondering if the mailbox module had a way
to do it.

One other question. Given a mailbox.Maildir folder like the one above,
is there a way to run through it and just get the headers? Basically,
the opposite of get_payload? I know I can scew around with msg.keys(),
but is there something like

for msg in folder:
hdr = msg.get_header()


Thanks for all your help. Sorry if this was unclear or long-winded.


Sep 11 '07 #1
0 1389

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Chuck Amadi | last post by:
Has anyone got a simple python script that will parse a linux mbox and create a large file to view . Cheers Chu
by: chuck amadi | last post by:
Hi , Im trying to parse a specific users mailbox (testwwws) and output the body of the messages to a file ,that file will then be loaded into a PostGresql DB at some point . I have read the...
by: noah | last post by:
Is there a way to figure out what filename an email object points to in a qmail style Maildir directory? Hmmm... I don't think so, but I'm hoping I wrong. I instantiated a Maildir mailbox and...
by: tinnews | last post by:
I am trying to write a utility to remove empty maildir mailboxes. It sounds like this should be very simple but it's proving really difficult. I'm doing this on a Fedora 7 system with python...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: Mushico | last post by:
How to calculate date of retirement from date of birth
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.