Email processing in Python (was: e-mail processing in C)

2008-03-24 Thread Giorgos Keramidas
On Mon, 24 Mar 2008 14:32:02 -0400, Robert Huff [EMAIL PROTECTED] wrote:
 I need to write a quick and not-too-dirty C program to process some
 e-mail.  (Including dealing with mbox files.)

 Is there a standard library to do this?  Respectfully,

No, there's no library for `email processing' in the C standard.  You
can probably find a lot of non-standard ones, by Googling however :)

It's worth writing that plain C is the wrong language for this sort of
thing, if you ask me.  There are excellent high-level libraries in Perl,
and Python to do this sort of thing.  Email processing is going to
require a log of string processing, and C is notoriously 'tricky' for
this sort of thing.

As an example of the expressiveness of using a higher level language,
you can display the authors of all the messages in a UNIX mailbox with
the following short Python script:

import mailbox
m = mailbox.mbox('/home/keramida/mbox')
for message in m:
author = m['from]
print author

This is not just a `readable pseudo-code-like example'.  It's *real*
Python code, that you can run _now_ in your Python shell.

To perform a similar task in plain C you will need several dozens of
lines of code, and it won't necessarily be as readable.  It _may_ be
faster, in some cases, but it will probably won't be as 'safe'.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Email processing in Python (was: e-mail processing in C)

2008-03-24 Thread Patrick C
Searching real quick shows the existence of both libmime and libmbox...
don't know if they're maintained. Another option would be to dig out the
associated code in pine, elm, or whatnot. See how they access mail.

-Patrick

On 24/03/2008, Giorgos Keramidas [EMAIL PROTECTED] wrote:

 On Mon, 24 Mar 2008 14:32:02 -0400, Robert Huff [EMAIL PROTECTED]
 wrote:
  I need to write a quick and not-too-dirty C program to process some
  e-mail.  (Including dealing with mbox files.)
 
  Is there a standard library to do this?  Respectfully,

 No, there's no library for `email processing' in the C standard.  You
 can probably find a lot of non-standard ones, by Googling however :)

 It's worth writing that plain C is the wrong language for this sort of
 thing, if you ask me.  There are excellent high-level libraries in Perl,
 and Python to do this sort of thing.  Email processing is going to
 require a log of string processing, and C is notoriously 'tricky' for
 this sort of thing.

 As an example of the expressiveness of using a higher level language,
 you can display the authors of all the messages in a UNIX mailbox with
 the following short Python script:

 import mailbox
 m = mailbox.mbox('/home/keramida/mbox')
 for message in m:
 author = m['from]
 print author

 This is not just a `readable pseudo-code-like example'.  It's *real*
 Python code, that you can run _now_ in your Python shell.

 To perform a similar task in plain C you will need several dozens of
 lines of code, and it won't necessarily be as readable.  It _may_ be
 faster, in some cases, but it will probably won't be as 'safe'.

 ___
 freebsd-questions@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to 
 [EMAIL PROTECTED]

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Email processing in Python (was: e-mail processing in C)

2008-03-24 Thread Robert Huff
Giorgos Keramidas writes:

  No, there's no library for `email processing' in the C standard.  You
  can probably find a lot of non-standard ones, by Googling however :)
  
  It's worth writing that plain C is the wrong language for this
  sort of thing, if you ask me.  There are excellent high-level
  libraries in Perl, and Python to do this sort of thing.

On one hand, that's probably true.
On the other hand: I know zero Python and this much   Perl.
I tried Perl, actually, and couldn't find the functions I needed.
(Plus the documemtation was aimed at a more experienced audience.)
I can fumble my way around a decent C packagei less time ad with
less hair-rending.
I do have the advantage I know more-or-less exactly what the
message will look like.


Robert Huff

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Email processing in Python (was: e-mail processing in C)

2008-03-24 Thread Erwan David
Le Mon 24/03/2008, Patrick C disait
 Searching real quick shows the existence of both libmime and libmbox...
 don't know if they're maintained. Another option would be to dig out the
 associated code in pine, elm, or whatnot. See how they access mail.
 
 -Patrick

libPAN (or is it libEtPAN ?) is also a C library for mail processing

-- 
Erwan
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: Email processing in Python (was: e-mail processing in C)

2008-03-24 Thread Jeffrey Goldberg

On Mar 24, 2008, at 2:04 PM, Patrick C wrote:


Another option would be to dig out the
associated code in pine, elm, or whatnot. See how they access mail.


What is used in pine (now alpine) is the c-client libraries already  
mentioned in another post.


-j


--
Jeffrey Goldberghttp://www.goldmark.org/jeff/

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]