MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / common_convert_value

Function common_convert_value

apps/common/utils/common.py:417–443  ·  view source on GitHub ↗
(_type, value)

Source from the content-addressed store, hash-verified

415
416
417def common_convert_value(_type, value):
418 if value is None:
419 return None
420
421 if _type == 'int':
422 return int(value)
423 if _type == 'boolean':
424 if isinstance(value, str) and value.lower() in ('false', '0', '[]', ''):
425 return False
426 return bool(value)
427 if _type == 'float':
428 return float(value)
429 if _type == 'dict':
430 if isinstance(value, dict):
431 return value
432 v = json.loads(value)
433 if isinstance(v, dict):
434 return v
435 raise Exception(_('type error'))
436 if _type == 'array':
437 if isinstance(value, list):
438 return value
439 v = json.loads(value)
440 if isinstance(v, list):
441 return v
442 raise Exception(_('type error'))
443 return value
444
445
446def reset_value(value):

Callers 5

convert_valueMethod · 0.90
convert_valueFunction · 0.90
convert_valueFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected