o a5@sPdZddlZddlmZddlmZddlmZm Z Gddde Z dd ZdS) z# Serialize data to/from JSON Lines N)DeserializationError)DjangoJSONEncoder) Deserializer Serializercs<eZdZdZdZddZddZddZfd d ZZ S) rz!Convert a queryset to JSON Lines.FcCsfd|_|j|_|jdd|jdd|jddd|jd<|jdt|jdddS) Nstreamfieldsindent),z: separatorscls ensure_asciiF)_currentoptionscopy json_kwargspop setdefaultrselfr?/usr/lib/python3/dist-packages/django/core/serializers/jsonl.py _init_optionss  zSerializer._init_optionscCs |dSN)rrrrrstart_serializations zSerializer.start_serializationcCs4tj|||jfi|j|jdd|_dS)N )jsondumpget_dump_objectrrwriter )robjrrr end_objects  zSerializer.end_objectcstt|Sr)superPythonSerializergetvaluer __class__rrr#%szSerializer.getvalue) __name__ __module__ __qualname____doc__internal_use_onlyrrr r# __classcell__rrr$rrs rc kst|tr |}t|ttfr|d}|D]1}|sqztt|gfi|EdHWqt t fy:t yI}zt |d}~wwdS)z,Deserialize a stream or string of JSON data.rN) isinstancebytesdecodestrsplitstripPythonDeserializerrloads GeneratorExitr Exception)stream_or_stringrlineexcrrrr*s"  "r) r)rdjango.core.serializers.baserdjango.core.serializers.jsonrdjango.core.serializers.pythonrr2rr"rrrrs