Utilities¶
Helper functions and utilities for logging and common operations.
Logger¶
getLogger(name)
¶
Logging Initialization¶
logging_init(cfg_path=None)
¶
Source code in ivcap_service/logger.py
General Utilities¶
utils
¶
get_input_type(func)
¶
Gets the input type of a function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func |
Callable
|
The function to get the input type for. |
required |
Returns:
| Type | Description |
|---|---|
tuple[type[BaseModel] | None, dict[str, Any]]
|
A tuple containing: - The first function parameter which is a derived class of a pydantic BaseModel, or None if no such parameter exists. - A dictionary of all additional parameters, where the key is the parameter name and the value is the type. |
Source code in ivcap_service/utils.py
get_function_return_type(func)
¶
Extracts the return type from a function.
Source code in ivcap_service/utils.py
file_to_json(file_path)
¶
Reads a file, attempts to parse it as JSON, and returns the content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path |
str
|
The path to the file to read. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary containing the parsed JSON content. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the file does not exist. |
ValueError
|
If the file is not a valid JSON file. |
IOError
|
If there is an error reading the file. |
Source code in ivcap_service/utils.py
clean_description(text)
¶
Cleans a string by removing unnecessary whitespace and newlines, while preserving double newlines.