(_type, value)
| 415 | |
| 416 | |
| 417 | def 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 | |
| 446 | def reset_value(value): |
no outgoing calls
no test coverage detected