Skip to content

Commit 7d17b32

Browse files
committed
Fixes exclude to work with lists
1 parent be82cec commit 7d17b32

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

Diff for: jdiff/extract_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def extract_data_from_json(data: Union[Mapping, List], path: str = "*", exclude:
3030
Returns:
3131
Evaluated data, may be anything depending on JMESPath used.
3232
"""
33-
if exclude and isinstance(data, Dict):
33+
if exclude and isinstance(data, (Dict, List)):
3434
if not isinstance(exclude, list):
3535
raise ValueError(f"Exclude list must be defined as a list. You have {type(exclude)}")
3636
# exclude unwanted elements

Diff for: tests/test_filter_parsers.py

+29
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,38 @@
2828
}
2929
},
3030
)
31+
exclude_filter_test_case_2 = (
32+
["interfaceStatistics"],
33+
[
34+
{
35+
"interfaces": {
36+
"Management1": {
37+
"name": "Management1",
38+
"interfaceStatus": "connected",
39+
"autoNegotiate": "success",
40+
"interfaceStatistics": {
41+
"inBitsRate": 3403.4362520883615,
42+
"inPktsRate": 3.7424095978179257,
43+
"outBitsRate": 16249.69114419833,
44+
"updateInterval": 300,
45+
"outPktsRate": 2.1111866059750692,
46+
},
47+
}
48+
}
49+
}
50+
],
51+
[
52+
{
53+
"interfaces": {
54+
"Management1": {"name": "Management1", "interfaceStatus": "connected", "autoNegotiate": "success"}
55+
}
56+
}
57+
],
58+
)
3159

3260
exclude_filter_tests = [
3361
exclude_filter_test_case_1,
62+
exclude_filter_test_case_2,
3463
]
3564

3665

0 commit comments

Comments
 (0)