f^ g d Z ddlZddlZddlZddlZddlmZ ddlmZ e j
Z
dZdZdZ
dZd Zd
ZdZ e
d Z e
d
Z ej dej ej z Z ej d Z ej d Zej j Zd Z ddZ G d d Z G d d Z G d de Z!dS ))Header
decode_headermake_header N)HeaderParseError)charset
z N z us-asciizutf-8ai
=\? # literal =?
(?P<charset>[^?]*?) # non-greedy up to the next ? is the charset
\? # literal ?
(?P<encoding>[qQbB]) # either a "q" or a "b", case insensitive
\? # literal ?
(?P<encoded>.*?) # non-greedy up to the next ?= is the encoded string
\?= # literal ?=
z[\041-\176]+:$z
\n[^ \t]+:c t | d rd | j D S t | s| d fgS g }| D ]}t | }d}|r| d }|r| }d}|r| |d d f |r{| d }| d }| d }| |||f |ƌg } t | D ]_\ }
}|
dk rT|d rL||
dz
d r;||
dz
d r| |
dz
`t | D ]}||= g }
|D ]\ }}}||
||f |dk r7t j | }|
||f ]|d k r~t! | d
z }|r|dd d
|z
z
} t j | }|
||f # t&