nanover.utilities.protobuf_utilities module
- nanover.utilities.protobuf_utilities.deep_copy_serializable_dict(dictionary: Dict[str, None | str | int | float | bool | Iterable[Any] | Mapping[str, Any] | Iterable[None | str | int | float | bool | Iterable[Any] | Mapping[str, Any]] | Mapping[str, None | str | int | float | bool | Iterable[Any] | Mapping[str, Any]]]) Dict[str, None | str | int | float | bool | Iterable[Any] | Mapping[str, Any] | Iterable[None | str | int | float | bool | Iterable[Any] | Mapping[str, Any]] | Mapping[str, None | str | int | float | bool | Iterable[Any] | Mapping[str, Any]]]
Makes a deep copy of a dictionary by converting it to a protobuf Struct and back. Only protobuf serializable elements will be preserved.
- nanover.utilities.protobuf_utilities.dict_to_struct(dictionary: Mapping[str, None | str | int | float | bool | Iterable[Any] | Mapping[str, Any] | Iterable[None | str | int | float | bool | Iterable[Any] | Mapping[str, Any]] | Mapping[str, None | str | int | float | bool | Iterable[Any] | Mapping[str, Any]]]) Struct
Converts a python dictionary to a protobuf
Struct
. The dictionary must consist of types that can be serialised.- Parameters:
dictionary – Dictionary to convert.
- Returns:
Struct
containing copies of all the items of the dictionary.
- nanover.utilities.protobuf_utilities.list_value_to_list(list: ListValue) List[None | str | int | float | bool | Iterable[Any] | Mapping[str, Any] | Iterable[None | str | int | float | bool | Iterable[Any] | Mapping[str, Any]] | Mapping[str, None | str | int | float | bool | Iterable[Any] | Mapping[str, Any]]]
Converts a protobuf
ListValue
to a python dictionary.- Parameters:
list –
ListValue
to convert.- Returns:
A list containing copies of all the items in the list value.
- nanover.utilities.protobuf_utilities.object_to_value(obj: None | str | int | float | bool | Iterable[Any] | Mapping[str, Any] | Iterable[None | str | int | float | bool | Iterable[Any] | Mapping[str, Any]] | Mapping[str, None | str | int | float | bool | Iterable[Any] | Mapping[str, Any]]) Value
Convert a python object in an equivalent protobuf Value. :param obj: A python object. :return: A protobuf Value equivalent to the given object.
- nanover.utilities.protobuf_utilities.struct_to_dict(struct: Struct) Dict[str, None | str | int | float | bool | Iterable[Any] | Mapping[str, Any] | Iterable[None | str | int | float | bool | Iterable[Any] | Mapping[str, Any]] | Mapping[str, None | str | int | float | bool | Iterable[Any] | Mapping[str, Any]]]
Converts a protobuf
Struct
to a python dictionary.- Parameters:
struct –
Struct
to convert.- Returns:
A dictionary containing copies of all the items in the struct.
- nanover.utilities.protobuf_utilities.value_to_object(value: Value) None | str | int | float | bool | Iterable[Any] | Mapping[str, Any] | Iterable[None | str | int | float | bool | Iterable[Any] | Mapping[str, Any]] | Mapping[str, None | str | int | float | bool | Iterable[Any] | Mapping[str, Any]]
Converts a protobuf Value into an equivalent python object. :param value: A protobuf Value to convert. :return: A python object equivalent to the given protobuf Value.