Package email :: Module header
[hide private]
[frames] | no frames]

Module header

Header encoding and decoding functionality.

Classes [hide private]
Header
Functions [hide private]
 
decode_header(header)
Decode a message header value without converting charset.
 
make_header(decoded_seq, maxlinelen=None, header_name=None, continuation_ws=' ')
Create a Header from a sequence of pairs as returned by decode_header()
 
_split_ascii(s, firstlen, restlen, continuation_ws, splitchars)
 
_binsplit(splittable, charset, maxlinelen)
Variables [hide private]
  NL = '\n'
  SPACE = ' '
  USPACE = u' '
  SPACE8 = ' '
  UEMPTYSTRING = u''
  MAXLINELEN = 76
  USASCII = us-ascii
  UTF8 = utf-8
  ecre = re.compile(r'(?ix)=\?(?P<charset>[^\?]*?)\?(?P<encoding...
  fcre = re.compile(r'[!-~]+:$')

Imports: re, binascii, email, HeaderParseError, Charset, _max_append


Function Details [hide private]

decode_header(header)

 

Decode a message header value without converting charset.

Returns a list of (decoded_string, charset) pairs containing each of the decoded parts of the header. Charset is None for non-encoded parts of the header, otherwise a lower-case string containing the name of the character set specified in the encoded string.

An email.Errors.HeaderParseError may be raised when certain decoding error occurs (e.g. a base64 decoding exception).

make_header(decoded_seq, maxlinelen=None, header_name=None, continuation_ws=' ')

 

Create a Header from a sequence of pairs as returned by decode_header()

decode_header() takes a header value string and returns a sequence of pairs of the format (decoded_string, charset) where charset is the string name of the character set.

This function takes one of those sequence of pairs and returns a Header instance. Optional maxlinelen, header_name, and continuation_ws are as in the Header constructor.


Variables Details [hide private]

ecre

Value:
re.compile(r'(?ix)=\?(?P<charset>[^\?]*?)\?(?P<encoding>[qb])\?(?P<enc\
oded>.*?)\?=')