(obj)
| 9 | |
| 10 | |
| 11 | def convert(obj): |
| 12 | if isinstance(obj, str): |
| 13 | return {"type": "string", "value": obj} |
| 14 | elif isinstance(obj, bool): |
| 15 | return {"type": "bool", "value": str(obj).lower()} |
| 16 | elif isinstance(obj, int): |
| 17 | return {"type": "integer", "value": str(obj)} |
| 18 | elif isinstance(obj, float): |
| 19 | return {"type": "float", "value": _normalize_float_str(str(obj))} |
| 20 | elif isinstance(obj, datetime.datetime): |
| 21 | val = _normalize_datetime_str(obj.isoformat()) |
| 22 | if obj.tzinfo: |
| 23 | return {"type": "datetime", "value": val} |
| 24 | return {"type": "datetime-local", "value": val} |
| 25 | elif isinstance(obj, datetime.time): |
| 26 | return { |
| 27 | "type": "time-local", |
| 28 | "value": _normalize_localtime_str(str(obj)), |
| 29 | } |
| 30 | elif isinstance(obj, datetime.date): |
| 31 | return { |
| 32 | "type": "date-local", |
| 33 | "value": str(obj), |
| 34 | } |
| 35 | elif isinstance(obj, list): |
| 36 | return [convert(i) for i in obj] |
| 37 | elif isinstance(obj, dict): |
| 38 | return {k: convert(v) for k, v in obj.items()} |
| 39 | raise Exception("unsupported type") |
| 40 | |
| 41 | |
| 42 | def normalize(obj: Any) -> Any: |
nothing calls this directly
no test coverage detected
searching dependent graphs…