Coverage for src/hatch_ci/text.py: 94%

# Coverage for src/hatch_ci/text.py : 94%

## 16 statements 15 run 1 missing 0 excluded

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | from __future__ import annotations def indent(txt: str, pre: str = " " * 2) -> str: """simple text indentation""" from textwrap import dedent txt = dedent(txt) if txt.endswith("\n"): last_eol = "\n" txt = txt[:-1] else: last_eol = "" result = pre + txt.replace("\n", "\n" + pre) + last_eol return result if result.strip() else result.strip() def lstrip(txt: str, ending: str | list[str]) -> str: endings = ending if isinstance(ending, list) else [ending] for left in endings: txt = txt[len(left) :] if txt.startswith(left) else txt return txt