1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
from __future__ import annotations
import re
from pathlib import Path
ROOT_DIR = Path(__file__).resolve().parent.parent
def dir_name(linter_name: str) -> str:
return linter_name.replace("-", "_")
def pascal_case(linter_name: str) -> str:
"""Convert from snake-case to PascalCase."""
return "".join(word.title() for word in linter_name.split("-"))
def snake_case(name: str) -> str:
"""Convert from PascalCase to snake_case."""
return "".join(
f"_{word.lower()}" if word.isupper() else word for word in name
).lstrip("_")
def get_indent(line: str) -> str:
return re.match(r"^\s*", line).group() # type: ignore[union-attr]
|