jdiff.utils.data_normalization
¶
Data Normalization utilities.
jdiff.utils.data_normalization.exclude_filter(data, exclude)
¶
Recusively look through all dict keys and pop out the one defined in "exclude".
Update in place existing dictionary. Look into unit test for example.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[Dict, List]
|
{ "interfaces": { "Management1": { "name": "Management1", "interfaceStatus": "connected", "autoNegotiate": "success", "interfaceStatistics": { "inBitsRate": 3403.4362520883615, "inPktsRate": 3.7424095978179257, "outBitsRate": 16249.69114419833, "updateInterval": 300, "outPktsRate": 2.1111866059750692 },... |
required |
exclude
|
List
|
["interfaceStatistics", "interfaceCounters"] |
required |
jdiff.utils.data_normalization.flatten_list(my_list)
¶
Flatten a multi level nested list and returns a list of lists.
This normalization step is required since jmespath can return nested lists containing the wanted value. This depends how much nested is the wanted value in the json output.
Having a list of lists will help us to assert that we have the number of values we have, will match the number of reference keys found in json object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
my_list
|
List
|
nested list to be flattened. |
required |
Return
[[-1, 0], [-1, 0], [-1, 0], ...]
Example
my_list = [[[[-1, 0], [-1, 0]]]] flatten_list(my_list) [[-1, 0], [-1, 0]]