power_balance.utilities#
Source: power_balance/utilities.py
Utilities for PowerBalance API
Contains assorted utility functions used within the Power Balance API
convert_to_value#
convert_to_value(value_str: Any) -> Any
expand_dictionary#
expand_dictionary(input_dict: Dict[str, Any], output_dict: Dict[str, Any] = None, separator: str = '.') -> Dict[str, Any]
Convert a single level dictionary with keys containing a separator into a nested dictionary.
Parameters#
-
input_dict
:typing.Dict
dictionary to expand
-
separator
:str
, default.
character which defines dictionary levels in key
-
Other arguments are for internal use.
Returns#
-
typing.Dict
expanded dictionary with nested levels
flatten_dictionary#
flatten_dictionary(input_dict: Dict[str, Any], output_dict: Dict[str, Any] = None, parent_key: str = None, separator: str = '.') -> Dict[str, Any]
Convert a dictionary of dictionaries into a single level dictionary with keys in the form A{separator}B
.
Parameters#
-
input_dict
:typing.Dict
input dictionary object to flatten
-
separator
:str
, default.
character to use for key address, by default "."
-
Other arguments are for internal use.
Returns#
-
typing.Dict
flattened single level dictionary representation of input dictionary with levels represented by the given separator