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 sequen
(decoded_seq, maxlinelen=None, header_name=None,
continuation_ws=' ')
| 157 | |
| 158 | |
| 159 | def make_header(decoded_seq, maxlinelen=None, header_name=None, |
| 160 | continuation_ws=' '): |
| 161 | """Create a Header from a sequence of pairs as returned by decode_header() |
| 162 | |
| 163 | decode_header() takes a header value string and returns a sequence of |
| 164 | pairs of the format (decoded_string, charset) where charset is the string |
| 165 | name of the character set. |
| 166 | |
| 167 | This function takes one of those sequence of pairs and returns a Header |
| 168 | instance. Optional maxlinelen, header_name, and continuation_ws are as in |
| 169 | the Header constructor. |
| 170 | |
| 171 | This function exists for backwards compatibility only, and is not |
| 172 | recommended for use in new code. |
| 173 | """ |
| 174 | h = Header(maxlinelen=maxlinelen, header_name=header_name, |
| 175 | continuation_ws=continuation_ws) |
| 176 | for s, charset in decoded_seq: |
| 177 | # None means us-ascii but we can simply pass it on to h.append() |
| 178 | if charset is not None and not isinstance(charset, Charset): |
| 179 | charset = Charset(charset) |
| 180 | h.append(s, charset) |
| 181 | return h |
| 182 | |
| 183 | |
| 184 | class Header: |
searching dependent graphs…