MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / make_header

Function make_header

tools/python-3.11.9-amd64/Lib/email/header.py:153–172  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

151
152
153def make_header(decoded_seq, maxlinelen=None, header_name=None,
154 continuation_ws=' '):
155 """Create a Header from a sequence of pairs as returned by decode_header()
156
157 decode_header() takes a header value string and returns a sequence of
158 pairs of the format (decoded_string, charset) where charset is the string
159 name of the character set.
160
161 This function takes one of those sequence of pairs and returns a Header
162 instance. Optional maxlinelen, header_name, and continuation_ws are as in
163 the Header constructor.
164 """
165 h = Header(maxlinelen=maxlinelen, header_name=header_name,
166 continuation_ws=continuation_ws)
167 for s, charset in decoded_seq:
168 # None means us-ascii but we can simply pass it on to h.append()
169 if charset is not None and not isinstance(charset, Charset):
170 charset = Charset(charset)
171 h.append(s, charset)
172 return h
173
174
175class Header:

Callers 1

sanitise_headerFunction · 0.90

Calls 3

appendMethod · 0.95
CharsetClass · 0.85
HeaderClass · 0.70

Tested by

no test coverage detected