welkin.util
Classes
Functions
|
Clean data for JSON serialization. |
|
|
|
|
|
|
|
|
|
|
|
Recursively traverse the _parent chain searching for a model id. |
|
Insert values for model_id arguments if not provided. |
|
Reset file-like objects to the beginning of the file. |
|
Convert a string to camelCase. |
|
Convert a string to snake_case. |
Module Contents
- class welkin.util.Target
- welkin.util.clean_data(value: Any) Any
Clean data for JSON serialization.
- Parameters:
value (Any) – The value to clean.
- Returns:
The cleaned value.
- Return type:
Any
- welkin.util.clean_request_payload(payload: dict) dict
- welkin.util.clean_json_list(data: list) list
- welkin.util.clean_request_params(params: dict) dict
- welkin.util.clean_date(date: clean_date.date) str
- welkin.util.clean_datetime(dt: datetime.datetime) str
- welkin.util.find_model_id(instance: welkin.models.base.Collection | welkin.models.base.Resource, model_name: str) str
Recursively traverse the _parent chain searching for a model id.
- Parameters:
instance (Union[Collection, Resource]) – The instanceect instance to inspect.
model_name (str) – The class name of the model to find.
- Raises:
AttributeError – If recursion ends without finding the model id.
- Returns:
The model id.
- Return type:
str
- welkin.util.model_id(*models: tuple[str]) Callable
Insert values for model_id arguments if not provided.
- Parameters:
*models (tuple[str]) – The model names to search for.
- Raises:
TypeError – If no ID is found and no arguments are provided.
- welkin.util.reset_file_offsets(files: list) None
Reset file-like objects to the beginning of the file.
- Parameters:
files (list) – The list of files from the request.
- welkin.util.to_camel_case(s: str) str
Convert a string to camelCase.
- Parameters:
s (str) – The string to convert.
- Returns:
The converted camelCase string.
- Return type:
str
- welkin.util.to_snake_case(s: str) str
Convert a string to snake_case.
- Parameters:
s (str) – The string to convert.
- Returns:
The converted snake_case string.
- Return type:
str