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

Method _make_boundary

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

Source from the content-addressed store, hash-verified

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