(bstr)
| 14 | # This is like textwrap.dedent for bytes, except that it uses \r\n for the line |
| 15 | # separators on the rebuilt string. |
| 16 | def 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 |
no test coverage detected
searching dependent graphs…