| Joel Uckelman on Wed, 1 Dec 2004 23:57:26 -0600 (CST) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
| Re: [nimh-dev] scan is easy too |
Thus spake Tom Plagge:
> #!/usr/bin/env python
>
> import email, os, string
>
> pth = "/home/tplagge/Mail/inbox"
>
> def parse_from(msg):
> return email.Utils.parseaddr(msg['From'])[0]
>
> def parse_date(msg):
> date = email.Utils.parsedate(msg['Date'])
> return string.zfill(str(date[1]),2) + "/" + string.zfill(str(date[2]),2)
>
> for file in os.listdir(pth):
> f = open(pth + "/" + file, 'r')
> if not file.startswith(",") and not file.startswith("."):
> msg = email.message_from_file(f)
> print file.rjust(5) + parse_date(msg).rjust(7) + " " + \
> parse_from(msg)[0:17].ljust(19) + msg['Subject'][0:40]
Do either of you know of a good book I could look at for learning the
syntax? I can tell what this does by looking at it, but I'm not sure I
could write something that worked properly without a Python reference.
--
J.
_______________________________________________
nimh-dev mailing list
nimh-dev@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/nimh-dev