MCPcopy Index your code
hub / github.com/python/cpython / _make_boundary

Method _make_boundary

Lib/email/generator.py:385–400  ·  view source on GitHub ↗
(cls, text=None)

Source from the content-addressed store, hash-verified

383 # at the end of the module. It *is* internal, so we could drop that...
384 @classmethod
385 def _make_boundary(cls, text=None):
386 # Craft a random boundary. If text is given, ensure that the chosen
387 # boundary doesn't appear in the text.
388 token = random.randrange(sys.maxsize)
389 boundary = ('=' * 15) + (_fmt % token) + '=='
390 if text is None:
391 return boundary
392 b = boundary
393 counter = 0
394 while True:
395 cre = cls._compile_re('^--' + re.escape(b) + '(--)?$', re.MULTILINE)
396 if not cre.search(text):
397 break
398 b = boundary + '.' + str(counter)
399 counter += 1
400 return b
401
402 @classmethod
403 def _compile_re(cls, s, flags):

Callers 1

_handle_multipartMethod · 0.95

Calls 5

strFunction · 0.85
randrangeMethod · 0.80
escapeMethod · 0.80
_compile_reMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected