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

Function dedent

Lib/test/test_email/test_inversion.py:16–23  ·  view source on GitHub ↗
(bstr)

Source from the content-addressed store, hash-verified

14# This is like textwrap.dedent for bytes, except that it uses \r\n for the line
15# separators on the rebuilt string.
16def dedent(bstr):
17 lines = bstr.splitlines()
18 if not lines[0].strip():
19 raise ValueError("First line must contain text")
20 stripamt = len(lines[0]) - len(lines[0].lstrip())
21 return b'\r\n'.join(
22 [x[stripamt:] if len(x)>=stripamt else b''
23 for x in lines])
24
25
26@parameterize

Callers 2

TestInversionClass · 0.70

Calls 4

splitlinesMethod · 0.45
stripMethod · 0.45
lstripMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…