docs: updating docstring, formatting

This commit is contained in:
Mose Müller 2023-08-02 12:06:21 +02:00
parent 5695d28ea3
commit 5fbbdd994c
2 changed files with 8 additions and 6 deletions

View File

@ -24,8 +24,6 @@ class DataServiceList(list):
method. method.
Attributes: Attributes:
_original_list (list):
Reference to the original list, to prevent it from being garbage collected.
callbacks (list): callbacks (list):
List of callback functions to be executed on item set. List of callback functions to be executed on item set.
""" """

View File

@ -77,8 +77,8 @@ def generate_paths_from_DataService_dict(
list[str]: A list with paths as elements. list[str]: A list with paths as elements.
Note: Note:
The function ignores keys whose "type" is "method", as these represent methods of the The function ignores keys whose "type" is "method", as these represent methods
DataService object and not its state. of the DataService object and not its state.
Example: Example:
------- -------
@ -155,14 +155,18 @@ def get_nested_value_by_path_and_key(data: dict, path: str, key: str = "value")
>>> data = { >>> data = {
>>> "attr1": {"type": "int", "value": 10}, >>> "attr1": {"type": "int", "value": 10},
>>> "attr2": {"type": "MyClass", "value": {"attr3": {"type": "float", "value": 20.5}}} >>> "attr2": {
"type": "MyClass",
"value": {"attr3": {"type": "float", "value": 20.5}}
}
>>> } >>> }
The function can be used to get the value of 'attr1' as follows: The function can be used to get the value of 'attr1' as follows:
>>> get_value_of_key_from_path(data, "attr1") >>> get_value_of_key_from_path(data, "attr1")
10 10
It can also be used to get the value of 'attr3', which is nested within 'attr2', as follows: It can also be used to get the value of 'attr3', which is nested within 'attr2',
as follows:
>>> get_value_of_key_from_path(data, "attr2.attr3", "type") >>> get_value_of_key_from_path(data, "attr2.attr3", "type")
float float
""" """