def _encode_range(obj): data = { '__start__': obj.start, '__stop__': obj.stop, '__step__': obj.step, } return coding.marker(obj, data)
def _encode_timedelta(obj): data = { '__days__': obj.days, '__seconds__': obj.seconds, '__microseconds__': obj.microseconds, } return coding.marker(obj, data)
def _encode_time(obj): # TODO: tz stuff, timespec stuff try: data = obj.isoformat() + 'Z' except AttributeError: data = obj.strftime(NAIVE_TIME_FORMAT) return coding.marker(obj, data)
def _encode_nonstringkey_proxy_sequence(obj): return coding.marker(obj, list(obj.encoded_items()))
def _encode_nonstringkey_proxy(obj): return coding.marker(obj, dict(obj.encoded_items()))
def _encode_complex(obj): data = {'__real__': obj.real, '__imag__': obj.imag} return coding.marker(obj, data)
def _encode_frozenset(obj): return coding.marker(obj, list(obj))
def _encode_tuple(obj): return coding.marker(obj, list(obj))
def _encode_date(obj): try: data = obj.isoformat() except AttributeError: data = obj.strftime(DATE_FORMAT) return coding.marker(obj, data)
def _encode_fraction(obj): return coding.marker(obj, str(obj))
def _encode_decimal(obj): return coding.marker(obj, str(obj))
def _encode_bytearray(obj): return coding.marker(obj, _decode_byte_objects(obj))