[Distutils] pkginfo python 3 port

Tres Seaver tseaver at palladion.com
Fri May 28 02:59:23 CEST 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Barry Warsaw wrote:
> On May 27, 2010, at 10:25 AM, Sridhar Ratnakumar wrote:
> 
>> Is there a way to parse a RFC 822 message in Python 3?
> 
> If it's ASCII, you should have no problems using email.parser.Parser.

The issue is that its behavior is subtly different from the now-removed
rfc822 parser::

  $ /opt/Python-2.6.5/bin/python
  Python 2.6.5 (r265:79063, Apr  6 2010, 14:45:18)
  [GCC 4.3.3] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> from StringIO import StringIO
  >>> with_multiline = StringIO("""\
  ... Description:  this is a multiline RFC 822
  ...               header.""")
  >>> from rfc822 import Message
  >>> rfc_msg = Message(with_multiline)
  >>> with_multiline.seek(0)
  >>> from email.parser import Parser
  >>> email_msg = Parser().parse(with_multiline)
  >>> rfc_msg.getheader('Description')
  'this is a multiline RFC 822\n header.'
  >>> email_msg.get('Description')
  'this is a multiline RFC 822\n              header.'



Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkv/FWsACgkQ+gerLs4ltQ67SwCeIWLyFj2c7rLb/cpcoxZ4sUzF
eHYAoInVb2cDZsIwOB0loSkZ3d9gAiDi
=Q1BW
-----END PGP SIGNATURE-----



More information about the Distutils-SIG mailing list