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

Method _fold

tools/python-3.11.9-amd64/Lib/email/policy.py:204–222  ·  view source on GitHub ↗
(self, name, value, refold_binary=False)

Source from the content-addressed store, hash-verified

202 return folded.encode(charset, 'surrogateescape')
203
204 def _fold(self, name, value, refold_binary=False):
205 if hasattr(value, 'name'):
206 return value.fold(policy=self)
207 maxlen = self.max_line_length if self.max_line_length else sys.maxsize
208 lines = value.splitlines()
209 refold = (self.refold_source == 'all' or
210 self.refold_source == 'long' and
211 (lines and len(lines[0])+len(name)+2 > maxlen or
212 any(len(x) > maxlen for x in lines[1:])))
213
214 if not refold:
215 if not self.utf8:
216 refold = not value.isascii()
217 elif refold_binary:
218 refold = _has_surrogates(value)
219 if refold:
220 return self.header_factory(name, ''.join(lines)).fold(policy=self)
221
222 return name + ': ' + self.linesep.join(lines) + self.linesep
223
224
225default = EmailPolicy()

Callers 2

foldMethod · 0.95
fold_binaryMethod · 0.95

Calls 6

_has_surrogatesFunction · 0.90
splitlinesMethod · 0.80
isasciiMethod · 0.80
anyFunction · 0.50
foldMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected