checksit.utils
Generic utility functions
Functions
|
Return file extension of string file name. |
|
Return file name up to the final underscore. |
|
Get all public functions from a module. |
|
Check if value is undefined. |
|
Convert function name to spec file rule name. |
Convert string value into dictionary. |
|
Convert string value into a list. |
- checksit.utils.extension(file_path: str) str[source]
Return file extension of string file name.
Returns the characters after the final “.” in a string, which in a file name is typically the extension denoting the file type.
- Parameters:
file_path – string of which to get the file extension
- Returns:
File extension as string.
- checksit.utils.get_file_base(file_path: str) str[source]
Return file name up to the final underscore.
Splits the file name by underscores, and returns the string up to the final underscore. For use with file names in the template cache.
- Parameters:
file_path – string of which to get the file base
- Returns:
File base as string.
- checksit.utils.get_public_funcs(module: object) List[Callable[[...], Any]][source]
Get all public functions from a module.
Get all public functions from a given module. Public functions are those that do not begin with an underscore.
- Parameters:
module – module from which to get public functions
- Returns:
List of public functions from the module.
- checksit.utils.is_undefined(x: Any) bool[source]
Check if value is undefined.
- Parameters:
x – value to check
- Returns:
True if value is undefined, False otherwise.
- checksit.utils.map_to_rule(func: Callable[[...], Any]) str[source]
Convert function name to spec file rule name.
Convert the function name into the rule name used in the spec files by replacing underscores with hyphens. Underscores cannot be used in the spec files, so hyphens are used instead. This function is used with the describe functionality in printing out rules and their docstrings to terminal.
- Parameters:
func – function to convert to rule name
- Returns:
Rule name as string, with underscores replaced by hyphens.
- checksit.utils.string_to_dict(s: str) Dict[str, str][source]
Convert string value into dictionary.
Takes a string value, splits string by comma into key-value pairs, splits the key-value pairs by “=”, and creates a dictionary for those keys and values.
- Parameters:
s – string to convert
- Returns:
Dictionary from string value.