refactor: Introduce get_indent helper for scripts

This commit is contained in:
Martin Fischer 2023-01-20 08:00:59 +01:00 committed by Charlie Marsh
parent 67ca50e9f2
commit ff6defc988
3 changed files with 12 additions and 10 deletions

View file

@ -1,4 +1,5 @@
import os
import re
from pathlib import Path
ROOT_DIR = Path(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@ -11,3 +12,7 @@ def dir_name(origin: str) -> str:
def pascal_case(origin: str) -> str:
"""Convert from snake-case to PascalCase."""
return "".join(word.title() for word in origin.split("-"))
def get_indent(line: str) -> str:
return re.match(r"^\s*", line).group() # pyright: ignore[reportOptionalMemberAccess]