123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263open!Baseletpython_of_bool=Py.Bool.of_boolletbool_of_python=Py.Bool.to_boolletpython_of_int=Py.Int.of_intletint_of_python=Py.Int.to_intletpython_of_float=Py.Float.of_floatletfloat_of_python=Py.Float.to_floatletpython_of_string=Py.String.of_stringletstring_of_python=Py.String.to_stringletpython_of_array=Py.List.of_array_mapletarray_of_python=Py.List.to_array_mapletpython_of_list=Py.List.of_list_mapletlist_of_python=Py.List.to_list_mapletpython_of_optionf=function|None->Py.none|Somev->fv;;letoption_of_pythonfpyobject=ifStdlib.(=)pyobjectPy.nonethenNoneelseSome(fpyobject);;moduleDict_str_keys=structtypet=Pytypes.pyobjectletinternalized_keys=Hashtbl.create(moduleString)letinternalized_keykey=Hashtbl.findi_or_addinternalized_keyskey~default:python_of_string;;letsettkeyvalue=letkey=internalized_keykeyinPy.Dict.set_itemtkeyvalue;;letfindtkey=letkey=internalized_keykeyinPy.Dict.findtkey;;letcreateassoc=lett=Py.Dict.create()inList.iterassoc~f:(fun(key,value)->settkeyvalue);t;;letfail_on_extra_fieldsdict~expected_field_names=letexpected_field_names=Set.of_list(moduleString)expected_field_namesinPy.Dict.to_bindings_stringdict|>List.filter~f:(fun(dict_field_name,_)->not(Set.memexpected_field_namesdict_field_name))|>List.map~f:(fun(field_name,_)->"'"^field_name^"'")|>String.concat~sep:","|>Printf.sprintf"unexpected extra field names %s"|>failwith;;endexceptionNot_found_s=Not_found_s