CodeTidy¶
- class chepy.modules.codetidy.CodeTidy(*data)¶
- beautify_json(indent: int = 2) CodeTidyT ¶
Beautify minified JSON
- Parameters
indent (int, optional) – Indent level. Defaults to 2.
- Returns
The Chepy object.
- Return type
Examples
>>> c = Chepy("/path/to/file.json").load_file() >>> print(c.beautify_json(indent=4))
- minify_json() CodeTidyT ¶
Minify JSON string
- Returns
The Chepy object.
- Return type
Examples
>>> c = Chepy("/path/to/file.json").load_file() >>> print(c.minify_json())
- swap_case() CodeTidyT ¶
Swap case in a string
- Returns
The Chepy object.
- Return type
Examples
>>> Chepy("SoMe TeXt").swap_case().o "sOmE tExT"
- to_camel_case(ignore_space: bool = False) CodeTidyT ¶
Convert string to camel case
Converts the input string to camel case. Camel case is all lower case except letters after word boundaries which are uppercase. e.g. thisIsCamelCase
- Parameters
ignore_space (bool, optional) – Ignore space boundaries. Defaults to False.
- Returns
The Chepy object.
- Return type
Examples
>>> Chepy("some Data_test").to_camel_case().o "someDataTest"
To ignore space, we can set the ignore_space to True >>> Chepy(“some Data_test”).to_camel_case(ignore_space=True).o “some DataTest”
- to_kebab_case() CodeTidyT ¶
Convert string to kebab case
Converts the input string to kebab case. Kebab case is all lower case with dashes as word boundaries. e.g. this-is-kebab-case.
- Returns
The Chepy object.
- Return type
Examples
>>> Chepy("Some data_test").to_kebab_case().o "some-data-test"
- to_leetspeak(special_chars: bool = True) CodeTidyT ¶
Convert string to l33t speak
- Parameters
special_chars (bool, optional) – Use special chars in conversion. Defaults to True.
- Returns
The Chepy object
- Return type
Examples
>>> Chepy("somexValue").to_leetspeak().o "50m3%V@1u3"
- to_lower_case() CodeTidyT ¶
Convert string to lowercase
Converts every character in the input to lower case.
- Returns
The Chepy object.
- Return type
Examples
>>> Chepy("HelLo WorLd").to_lower_case().o "hello world"
- to_snake_case() CodeTidyT ¶
Convert string to snake case
Converts the input string to snake case. Snake case is all lower case with underscores as word boundaries. e.g. this_is_snake_case.
- Returns
The Chepy object.
- Return type
Examples
>>> Chepy("helloWorld").to_snake_case().o "hello_world"
- to_upper_case(by: str = 'all') CodeTidyT ¶
Convert string to uppercase
- Parameters
by (str, optional) – Convert all, by word or by sentence. Defaults to ‘all’.
- Returns
The Chepy object.
- Return type
Examples
Uppercase by word
>>> Chepy("some String").to_upper_case(by="word").o "Some String"
Uppercase by sentence
>>> Chepy("some String").to_upper_case(by="sentence").o "Some string"
Uppercase all
>>> Chepy("some String").to_upper_case(by="all").o "SOME STRING"