MCPcopy Index your code
hub / github.com/diffgram/diffgram / input_check_many

Function input_check_many

shared/regular/regular_input.py:225–269  ·  view source on GitHub ↗

Want to check all names we expect that's why not using a .keys() method Arguments spec_list, a list of dicts to check format: variable name : type ex. {"name" : str} log, dict using regular.regular_log

(spec_list,
                     log,
                     untrusted_input,
                     string_len_not_zero = True)

Source from the content-addressed store, hash-verified

223
224
225def input_check_many(spec_list,
226 log,
227 untrusted_input,
228 string_len_not_zero = True):
229 """
230 Want to check all names we expect
231 that's why not using a .keys() method
232
233 Arguments
234 spec_list, a list of dicts to check
235 format:
236 variable name : type
237 ex.
238 {"name" : str}
239 log, dict using regular.regular_log
240 untrusted_input, dict of untrusted input
241
242 Returns
243 log
244 Updated,
245 errors are stored in log["error"][name]
246
247 input
248 dict of variables where key is the name
249 and value is value from untrusted dict OR None
250
251 The assumption is that we run something like
252 if len(log["error"].keys()) >= 1:
253 return jsonify(log=log), 400
254 """
255 input = {}
256
257 if isinstance(untrusted_input, dict) is False:
258 log["error"]["input"] = "Expecting dict"
259 return log, None
260
261 for spec in spec_list:
262 log, variable, name = input_check(spec = spec,
263 log = log,
264 untrusted_input = untrusted_input,
265 string_len_not_zero = string_len_not_zero
266 )
267 input[name] = variable
268
269 return log, input
270
271
272def master(request,

Callers 1

masterFunction · 0.85

Calls 1

input_checkFunction · 0.85

Tested by

no test coverage detected