Message236200
There is no reason to move this to the email package. email can already parse headers just fine. It might be useful to have a parse_header utility method, though, since currently the easiest way to parse a single header using the email package is:
>>> from email.policy import HTTP
>>> from email.parser import Parser
>>> m = Parser(policy=HTTP).parsestr('Content-Type: text/plain; filename="foo"\n\n')
>>> m['Content-Type'].content_type
'text/plain'
>>> m['Content-type'].params
mappingproxy({'filename': 'foo'})
Which isn't as straightforward as the parse_header API when you are only interested in a single header.
It might also be useful to have the email MIME headers grow a 'value' attribute to return whatever the value is (in this case, text/plain), so it can be accessed regardless of the header type.
I would make parse_header be a utility method of the policy, I think. Then the email API would be:
from email.policy import HTTP
h = HTTP.parse_header('Content-Type: ...')
value, params = h.value, h.params
It would then be trivial to implement the backward compatibility shim for the CGI parse_header method using the above. |
|
Date |
User |
Action |
Args |
2015-02-18 23:06:05 | r.david.murray | set | recipients:
+ r.david.murray, barry, janssen, orsenthil, mgiuca, flox, martin.panter |
2015-02-18 23:06:05 | r.david.murray | set | messageid: <1424300765.01.0.781603670866.issue3609@psf.upfronthosting.co.za> |
2015-02-18 23:06:04 | r.david.murray | link | issue3609 messages |
2015-02-18 23:06:04 | r.david.murray | create | |
|