MCPcopy Index your code
hub / github.com/RustPython/RustPython / fold

Method fold

Lib/email/headerregistry.py:227–253  ·  view source on GitHub ↗

Fold header according to policy. The parsed representation of the header is folded according to RFC5322 rules, as modified by the policy. If the parse tree contains surrogateescaped bytes, the bytes are CTE encoded using the charset 'unknown-8bit". Any non-

(self, *, policy)

Source from the content-addressed store, hash-verified

225 return str.__new__(cls, value)
226
227 def fold(self, *, policy):
228 """Fold header according to policy.
229
230 The parsed representation of the header is folded according to
231 RFC5322 rules, as modified by the policy. If the parse tree
232 contains surrogateescaped bytes, the bytes are CTE encoded using
233 the charset 'unknown-8bit".
234
235 Any non-ASCII characters in the parse tree are CTE encoded using
236 charset utf-8. XXX: make this a policy setting.
237
238 The returned value is an ASCII-only string possibly containing linesep
239 characters, and ending with a linesep character. The string includes
240 the header name and the ': ' separator.
241
242 """
243 # At some point we need to put fws here if it was in the source.
244 header = parser.Header([
245 parser.HeaderLabel([
246 parser.ValueTerminal(self.name, 'header-name'),
247 parser.ValueTerminal(':', 'header-sep')]),
248 ])
249 if self._parse_tree:
250 header.append(
251 parser.CFWSList([parser.WhiteSpaceTerminal(' ', 'fws')]))
252 header.append(self._parse_tree)
253 return header.fold(policy=policy)
254
255
256def _reconstruct_header(cls_name, bases, value):

Callers

nothing calls this directly

Calls 1

appendMethod · 0.95

Tested by

no test coverage detected