Skip to content

structlint.utils

Small and simple utility functions.

get_project_root() -> Path

default_module_root_dir() -> Path

default_module_name() -> str

move_path(p: str | Path, old_base: Path, new_base: Path) -> Path

always_true(s: str) -> bool

assert_bool(b: bool) -> bool

sort_on_path(strings: Iterable[str]) -> list[str]

boolean_merge(incumbent: dict, challenger: dict) -> dict

deduplicate_ordered(strings: Iterable[str]) -> list[str]

filter_with(string_set: set[str], contained: str | set[str]) -> set[str]

filter_without(string_set: set[str], contained: str | set[str]) -> set[str]

remove_ordering_index(s: str) -> str

prepend_module_name(s: str, module_name: str) -> str

dedup_underscores(s: str) -> str

remove_body(s: str) -> str

make_regex(s: str) -> re.Pattern

compile_for_path_segment(s: str | list[str]) -> re.Pattern

compile_string_or_bool(s: str | bool) -> re.Pattern

get_method_name(s: str) -> str

path_matches(p: Path | str, path_pattern: re.Pattern) -> Path | Literal[False]

path_matches_not(p: Path | str, path_pattern: re.Pattern) -> bool

Color

Simple utility to add ANSI color codes to a string, including the reset at the end.

black(s: str) -> str staticmethod

blue(s: str) -> str staticmethod

cyan(s: str) -> str staticmethod

green(s: str) -> str staticmethod

magenta(s: str) -> str staticmethod

no_color(s: str) -> str staticmethod

red(s: str) -> str staticmethod

white(s: str) -> str staticmethod

yellow(s: str) -> str staticmethod

make_colorize_path(specific_dir: Path, root_dir: Path) -> Callable[[str], str]

make_double_bar(s: str = '', colorizer: Callable[[str], str] = Color.no_color) -> str

make_bar(s: str = '', colorizer: Callable[[str], str] = Color.no_color) -> str