Jon Stewart on Mon, 6 Dec 2004 12:39:52 -0600 (CST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [nimh-dev] inc


> So, here's a sketch, adapted from the docs for the mailbox module:
> 
> import email
> import email.Errors
> import mailbox
> 
> # NB: we can make this return whatever we want;
> # maybe files would be better than email.Messages (or our subclass)?


Yes. Files would be better. Once they're copied, then we can treat them as 
messages.


> def make_email(fp):
>   try:
>     return email.message_from_file(fp)
>   except email.Errors.MessageParseError:
>     # Don't return None since that will
>     # stop the mailbox iterator
>     return ''
> 
> # TODO: read MH stuff
> # TODO: figure out what to inc from (read .mh_profile:MailDrop)
> # TODO: figure out what kind MailDrop is (proposal: Maildirs end in /)
> # TODO: lock the spool (?) if we're reading from the spool
> # TODO: figure out what folder to inc to
> 
> if mbox:
>   fp = file(boxpath, "r+")
>   box = mailbox.UnixMailbox(fp) 
> elif maildir:
>   box = mailbox.Maildir(boxpath)
> 
> while 1:  # it irriates me that you can't do assignment
>           # in a while loop condition


I think you can rewrite this as:

for m in box:
  # all the stuff

If something has a next(), it's usually iterable.

>   m = box.next()
>   if m is None: break
>   else:
>     # TODO: write m into its new home
>     # TODO: print the scan line for m
>     # TODO: for Maildirs, delete m from the Maildir on successful write
> 
> # TODO: do something to truncate the spool if we're reading from it


Looks good. Does the mailbox module support locking? That would be nifty.


Jon
-- 
Jon Stewart                                 Advanced Los Angeles C++
stew1@xxxxxxxxxxx                           http://www.alacpp.org
_______________________________________________
nimh-dev mailing list
nimh-dev@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/nimh-dev