def encode_timetable(var: Timetable) -> Dict[str, Any]: """Encode a timetable instance. This delegates most of the serialization work to the type, so the behavior can be completely controlled by a custom subclass. """ return {"type": as_importable_string(type(var)), "value": var.serialize()}
def _encode_timetable(var: Timetable) -> Dict[str, Any]: """Encode a timetable instance. This delegates most of the serialization work to the type, so the behavior can be completely controlled by a custom subclass. """ timetable_class = type(var) importable_string = as_importable_string(timetable_class) if _get_registered_timetable(importable_string) is None: raise _TimetableNotRegistered(importable_string) return {Encoding.TYPE: importable_string, Encoding.VAR: var.serialize()}