123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112openBaseopenPolyincludePpx_python_runtimetypepyobject=Pytypes.pyobjectletpython_of_pyobject=Fn.idletpyobject_of_python=Fn.idmoduleConvert_as_string(M:Stringable.S)=structletpython_of_tt=M.to_stringt|>python_of_stringlett_of_pythonp=string_of_pythonp|>M.of_stringendletget_classp=Option.bind(Py.Object.get_attr_stringp"__class__")~f:(funcls->Option.map(Py.Object.get_attr_stringcls"__name__")~f:Py.String.to_string);;moduleOne_or_tuple=struct(* 'a should not be encoded as a python tuple or none! *)type'at='alistletpython_of_tpython_of_at=matchtwith|[]->Py.none|[v]->python_of_av|vs->Py.Tuple.of_list_mappython_of_avs;;lett_of_pythona_of_pythonp=try[a_of_pythonp]with|_->ifp=Py.nonethen[]elseifPy.Tuple.checkpthenPy.Tuple.to_list_mapa_of_pythonpelsefailwith"incorrect python type";;endletto_iterablep=ifPy.List.checkpthenSomepelse(matchget_classpwith|Some"Series"->letp=Py.Module.get_function_with_keywordsp"tolist"[||][]inSomep|_->ifPy.Iter.checkpthenSomepelseNone);;moduleOne_or_tuple_or_list=struct(* 'a should not be encoded as a python tuple, list or none! *)type'at='alistletpython_of_t=One_or_tuple.python_of_tlett_of_pythona_of_pythonp=tryOne_or_tuple.t_of_pythona_of_pythonpwith|_->(matchto_iterablepwith|Somel->Py.List.to_list_mapa_of_pythonl|None->failwith"incorrect python type");;endmoduleOr_error_python=structtypeerr={caml_error:string}[@@derivingpython]type'at='aOr_error.tlett_of_pythonok_of_pythonp=matchok_of_pythonpwith|v->Okv|exceptionexn->Or_error.of_exnexn;;letpython_of_tpython_of_at=matchtwith|Oka->python_of_aa|Errorerr->python_of_err{caml_error=Error.to_string_humerr};;endletvalue_errorffmt=Printf.ksprintf(funmsg->raise(Py.Err(ValueError,msg)))fmtmoduleOne_or_tuple_or_list_or_error=structtype'at='aOr_error_python.tlistletpython_of_t=One_or_tuple_or_list.python_of_tlett_of_pythona_of_pythonp~type_name=matchOne_or_tuple.t_of_pythona_of_pythonpwith|v->List.mapv~f:(funv->Okv)|exception_->(matchto_iterablepwith|Somep->Py.List.to_list_map(funp->Or_error_python.t_of_pythona_of_pythonp|>Or_error.tag~tag:("trying to parse as "^type_name))p|None->failwith"incorrect python type");;end