hydra.formatting module
String formatting types and functions.
- hydra.formatting.capitalize(v1: str) str
Capitalize the first letter of a string.
- hydra.formatting.convert_case(from_: CaseConvention, to: CaseConvention, original: str) str
Convert a string from one case convention to another.
- hydra.formatting.convert_case_camel_or_underscore_to_lower_snake(s: str) str
Convert a string from camel case (possibly with underscores) to lower snake case. Splits on underscores first, then converts each part from camel case.
- hydra.formatting.convert_case_camel_to_lower_snake(v1: str) str
Convert a string from camel case to lower snake case.
- hydra.formatting.convert_case_camel_to_upper_snake(v1: str) str
Convert a string from camel case to upper snake case.
- hydra.formatting.convert_case_pascal_to_upper_snake(v1: str) str
Convert a string from pascal case to upper snake case.
- hydra.formatting.decapitalize(v1: str) str
Decapitalize the first letter of a string.
- hydra.formatting.escape_with_underscore(reserved: Set[str], s: str) str
Escape reserved words by appending an underscore.
- hydra.formatting.indent_lines(s: str) str
Indent each line of a string with four spaces.
- hydra.formatting.java_style_comment(s: str) str
Format a string as a Java-style block comment.
- hydra.formatting.lines(s: str) Sequence[str]
Split a string into lines on newline (U+000A); a trailing newline is consumed without producing an empty trailing element, and the empty string yields the empty list.
- hydra.formatting.map_first_letter(mapping: Callable[[str], str], s: str) str
A helper which maps the first letter of a string to another string.
- hydra.formatting.non_alnum_to_underscores(input: str) str
Replace sequences of non-alphanumeric characters with single underscores.
- hydra.formatting.normalize_comment(s: str) str
Normalize a comment string for consistent output across coders.
- hydra.formatting.sanitize_with_underscores(reserved: Set[str], s: str) str
Sanitize a string by replacing non-alphanumeric characters and escaping reserved words.
- hydra.formatting.show_list(f: Callable[[T0], str], els: Sequence[T0]) str
Format a list of elements as a bracketed, comma-separated string.
- hydra.formatting.strip_leading_and_trailing_whitespace(s: str) str
Remove leading and trailing whitespace from a string.
- hydra.formatting.unlines(xs: Sequence[str]) str
Join a list of strings with newlines (U+000A), appending a newline after each element including the last; the empty list yields the empty string.
- hydra.formatting.with_character_aliases(original: str) str
Replace special characters with their alphanumeric aliases.
- hydra.formatting.wrap_line(maxlen: int, input: str) str
A simple soft line wrap which is suitable for code comments.