MCPcopy Create free account
hub / github.com/StackStorm/st2 / get_value

Function get_value

st2client/st2client/utils/jsutil.py:80–97  ·  view source on GitHub ↗
(doc, key)

Source from the content-addressed store, hash-verified

78
79
80def get_value(doc, key):
81 if not key:
82 raise ValueError("key is None or empty: '{}'".format(key))
83
84 if not isinstance(doc, dict):
85 raise ValueError(
86 "doc is not an instance of dict: type={} value='{}'".format(type(doc), doc)
87 )
88 # jsonpath_rw can be very slow when processing expressions.
89 # In the case of a simple expression we've created a "fast path" that avoids
90 # the complexity introduced by running jsonpath_rw code.
91 # For more complex expressions we fall back to using jsonpath_rw.
92 # This provides flexibility and increases performance in the base case.
93 match = SIMPLE_EXPRESSION_REGEX_CMPL.match(key)
94 if match:
95 return _get_value_simple(doc, key)
96 else:
97 return _get_value_complex(doc, key)
98
99
100def get_kvps(doc, keys):

Callers 1

get_kvpsFunction · 0.85

Calls 4

_get_value_simpleFunction · 0.85
_get_value_complexFunction · 0.85
formatMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected