Skip to content

Commit 6eb66ea

Browse files
authored
Merge pull request #57 from networktocode-llc/lvrfrc87
add default value for JMSPath
2 parents b57dbc6 + 9470fe9 commit 6eb66ea

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

netcompare/check_types.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""CheckType Implementation."""
22
import re
3+
import warnings
34
from typing import Mapping, Tuple, List, Dict, Any, Union
45
from abc import ABC, abstractmethod
56
import jmespath
@@ -38,7 +39,7 @@ def init(check_type: str):
3839
raise NotImplementedError
3940

4041
@staticmethod
41-
def get_value(output: Union[Mapping, List], path: str, exclude: List = None) -> Any:
42+
def get_value(output: Union[Mapping, List], path: str = "*", exclude: List = None) -> Any:
4243
"""Return data from output depending on the check path. See unit test for complete example.
4344
4445
Get the wanted values to be evaluated if JMESPath expression is defined,
@@ -62,6 +63,10 @@ def get_value(output: Union[Mapping, List], path: str, exclude: List = None) ->
6263
exclude_filter(output, exclude) # exclude unwanted elements
6364

6465
if not path:
66+
warnings.warn("JMSPath cannot be of type 'None'. Path argumente reverted to default value '*'")
67+
path = "*"
68+
69+
if path == "*":
6570
return output # return if path is not specified
6671

6772
values = jmespath.search(jmespath_value_parser(path), output)

0 commit comments

Comments
 (0)