§ x<ˆjñãóŒ—dZddlZddlmZmZddlmZmZmZdZdZ dZ dZ Gd „d ¦«Z dd „Z dd„Zdd„Zdd„Zdd„ZdS)z÷Implementation of the JSON adaptation objects This module exists to avoid a circular import problem: pyscopg2.extras depends on psycopg2.extension, so I can't create the default JSON typecasters in extensions importing register_json from extras. éN)Ú ISQLQuoteÚ QuotedString)Únew_typeÚnew_array_typeÚ register_typeéréÇiÚißcó8—eZdZdZd d„Zd„Zd„Zd„Zd„Zd„Z dS) ÚJsona An `~psycopg2.extensions.ISQLQuote` wrapper to adapt a Python object to :sql:`json` data type. `!Json` can be used to wrap any object supported by the provided *dumps* function. If none is provided, the standard :py:func:`json.dumps()` is used. NcóH—||_d|_|p tj|_dS©N)ÚadaptedÚ_connÚjsonÚdumpsÚ_dumps)Úselfrrs úb/builddir/build/BUILD/cloudlinux-venv-1.0.12/venv/lib64/python3.11/site-packages/psycopg2/_json.pyÚ__init__z Json.__init__8s"€ØˆŒ ؈Œ ØÐ)�tœzˆŒ ˆ ˆ ócó—|tur|SdSr )r)rÚprotos rÚ __conform__zJson.__conform__=s€Ø •IРР؈Kð Ð rcó,—| |¦«S)zßSerialize *obj* in JSON format. The default is to call `!json.dumps()` or the *dumps* function provided in the constructor. You can override this method to create a customized JSON wrapper. )r)rÚobjs rrz Json.dumpsAs€ð�{Š{˜3ÑÔÐrcó—||_dSr )r)rÚconns rÚpreparez Json.prepareJs €ØˆŒ ˆ ˆ rcó¾—| |j¦«}t|¦«}|j�| |j¦«| ¦«Sr )rrrrrÚ getquoted)rÚsÚqss rr zJson.getquotedMsJ€Ø �JŠJ�t”|Ñ $Ô $ˆÝ ˜!‰_Œ_ˆØ Œ:Ð !Ø �JŠJ�t”zÑ "Ô "Ð "Ø�|Š|‰~Œ~ÐrcóR—| ¦« dd¦«S)NÚasciiÚreplace)r Údecode)rs rÚ__str__z Json.__str__Ts"€à�~Š~ÑÔ×&Ò& w° Ñ:Ô:Ð:rr ) Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrr r'©rrr r .s}€€€€€ððð*ð*ð*ð*ð ððð ð ð ððððððð;ð;ð;ð;ð;rr FrcóÜ—|€t||¦«\}}t|||| ¦«¬¦«\}}t|| r|pd¦«|�t|| r|pd¦«||fS)aCreate and register typecasters converting :sql:`json` type to Python objects. :param conn_or_curs: a connection or cursor used to find the :sql:`json` and :sql:`json[]` oids; the typecasters are registered in a scope limited to this object, unless *globally* is set to `!True`. It can be `!None` if the oids are provided :param globally: if `!False` register the typecasters only on *conn_or_curs*, otherwise register them globally :param loads: the function used to parse the data into a Python object. If `!None` use `!json.loads()`, where `!json` is the module chosen according to the Python version (see above) :param oid: the OID of the :sql:`json` type if known; If not, it will be queried on *conn_or_curs* :param array_oid: the OID of the :sql:`json[]` array type if known; if not, it will be queried on *conn_or_curs* :param name: the name of the data type to look for in *conn_or_curs* The connection or cursor passed to the function will be used to query the database and look for the OID of the :sql:`json` type (or an alternative type if *name* if provided). No query is performed if *oid* and *array_oid* are provided. Raise `~psycopg2.ProgrammingError` if the type is not found. N)ÚloadsÚname)Ú_get_json_oidsÚ_create_json_typecastersÚupperr)Ú conn_or_cursÚgloballyr.ÚoidÚ array_oidr/ÚJSONÚ JSONARRAYs rÚ register_jsonr9Ys�€ð2 €{Ý'¨ °dÑ;Ô;‰ˆˆYå.Ø ˆY˜e¨$¯*ª*©,¬,ð8ñ8ô8�O€Dˆ)õ�$˜H˜ Ð5¨Ð=¸Ñ>Ô>Ð>àÐÝ�i X Ð!>°,Ð!FÀ$ÑGÔGÐGà �ˆ?Ðrcó>—t|||tt¬¦«S)a{ Create and register :sql:`json` typecasters for PostgreSQL 9.2 and following. Since PostgreSQL 9.2 :sql:`json` is a builtin type, hence its oid is known and fixed. This function allows specifying a customized *loads* function for the default :sql:`json` type without querying the database. All the parameters have the same meaning of `register_json()`. )r3r4r.r5r6)r9ÚJSON_OIDÚ JSONARRAY_OID©r3r4r.s rÚregister_default_jsonr>€s&€õ  l¸XØ�­]ð <ñ <ô <ð.typecast_jsonŸsø€Ø ˆ9Ø�4؈u�Q‰xŒxˆrÚARRAY)rr.rr)r5r6r.r/rGr7r8s ` rr1r1šsmø€à €}Ý” ˆðððððõ �S�G˜T =Ñ 1Ô 1€DØÐÝ" I =°T°.°.°.À$ÑGÔGˆ ˆ àˆ à �ˆ?ÐrcóB—ddlm}ddlm}||¦«\}}|j}|jjdkrdpd}| d|z|f¦«| ¦«}||kr|j s|  ¦«|s|  |›d�¦«‚|S) Nr)ÚSTATUS_IN_TRANSACTION)Ú_solve_conn_cursi¬9ÚtyparrayÚNULLz6SELECT t.oid, %s FROM pg_type t WHERE t.typname = %%s;z data type not found) Úpsycopg2.extensionsrJÚpsycopg2.extrasrKÚstatusÚinfoÚserver_versionÚexecuteÚfetchoneÚ autocommitÚrollbackÚProgrammingError) r3r/rJrKrÚcursÚ conn_statusrLÚrs rr0r0­sâ€à9Ð9Ð9Ð9Ð9Ð9Ø0Ð0Ð0Ð0Ð0Ð0à!Ð! ,Ñ/Ô/�J€Dˆ$ð”+€KðŒyÔ'¨5Ò0Ð?°ZÐIÀ6€Hð ‡L‚LØ@Ø ñ Ø�Gñôðð � Š ‰Œ€AðÐ+Ò+Ð+°D´OÐ+Ø � Š ‰Œˆà ðCØ×#Ò# tÐ$AÐ$AÐ$AÑBÔBÐBà €Hr)NFNNNr)NFN)Nr7)r)r+rÚpsycopg2._psycopgrrrrrr;r<rArBr r9r>rCr1r0r,rrúr\s ðððð< € € € à5Ð5Ð5Ð5Ð5Ð5Ð5Ð5ØEÐEÐEÐEÐEÐEÐEÐEÐEÐEð €Ø€ ð € Ø€ð(;ð(;ð(;ð(;ð(;ñ(;ô(;ð(;ðV<@Ø17ð$ð$ð$ð$ðN <ð <ð <ð <ð Lð Lð Lð Lððððð& ð ð ð ð ð r