1+ """Reference key utilities."""
12from typing import Mapping , List
23
34
45def keys_cleaner (wanted_reference_keys : Mapping ) -> List [Mapping ]:
5- """
6- Get every required reference key from output.
7- """
6+ """Get every required reference key from output."""
87 if isinstance (wanted_reference_keys , list ):
98 return wanted_reference_keys
109
11- elif isinstance (wanted_reference_keys , dict ):
12- my_keys_list = list ()
10+ if isinstance (wanted_reference_keys , dict ):
11+ my_keys_list = []
1312
1413 if isinstance (wanted_reference_keys , dict ):
1514 for key in wanted_reference_keys .keys ():
@@ -21,12 +20,12 @@ def keys_cleaner(wanted_reference_keys: Mapping) -> List[Mapping]:
2120
2221 return my_keys_list
2322
23+ return None
24+
2425
2526def keys_values_zipper (list_of_reference_keys : List , wanted_value_with_key : List ) -> List :
26- """
27- Build dictionary zipping keys with relative values.
28- """
29- final_result = list ()
27+ """Build dictionary zipping keys with relative values."""
28+ final_result = []
3029
3130 if len (list_of_reference_keys ) != len (wanted_value_with_key ):
3231 raise ValueError ("Keys len != from Values len" )
@@ -38,10 +37,7 @@ def keys_values_zipper(list_of_reference_keys: List, wanted_value_with_key: List
3837
3938
4039def associate_key_of_my_value (paths : str , wanted_value : List ) -> List :
41- """
42- Associate each key defined in path to every value found in output.
43- """
44-
40+ """Associate each key defined in path to every value found in output."""
4541 # global.peers.*.[is_enabled,is_up] / result.[*].state
4642 find_the_key_of_my_values = paths .split ("." )[- 1 ]
4743
@@ -53,10 +49,10 @@ def associate_key_of_my_value(paths: str, wanted_value: List) -> List:
5349 else :
5450 my_key_value_list = [find_the_key_of_my_values ]
5551
56- final_list = list ()
52+ final_list = []
5753
5854 for items in wanted_value :
59- temp_dict = dict ()
55+ temp_dict = {}
6056
6157 if len (items ) != len (my_key_value_list ):
6258 raise ValueError ("Key's value len != from value len" )
0 commit comments