Equivalent of textwrap.dedent that ignores unindented first line. This means it will still dedent strings like: '''foo is a bar ''' For use in wrap_paragraphs.
(text: str)
| 350 | |
| 351 | |
| 352 | def dedent(text: str) -> str: |
| 353 | """Equivalent of textwrap.dedent that ignores unindented first line. |
| 354 | |
| 355 | This means it will still dedent strings like: |
| 356 | '''foo |
| 357 | is a bar |
| 358 | ''' |
| 359 | |
| 360 | For use in wrap_paragraphs. |
| 361 | """ |
| 362 | |
| 363 | if text.startswith('\n'): |
| 364 | # text starts with blank line, don't ignore the first line |
| 365 | return textwrap.dedent(text) |
| 366 | |
| 367 | # split first line |
| 368 | splits = text.split('\n',1) |
| 369 | if len(splits) == 1: |
| 370 | # only one line |
| 371 | return textwrap.dedent(text) |
| 372 | |
| 373 | first, rest = splits |
| 374 | # dedent everything but the first line |
| 375 | rest = textwrap.dedent(rest) |
| 376 | return '\n'.join([first, rest]) |
| 377 | |
| 378 | |
| 379 | def strip_email_quotes(text: str) -> str: |
no outgoing calls
searching dependent graphs…