§ x<ˆjñ ã óŒ — d Z ddlZddlmZmZ ddlmZmZmZ dZdZ dZ dZ G d „ 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 — e Zd ZdZd 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 | _ |pt j | _ d S ©N)ÚadaptedÚ_connÚjsonÚdumpsÚ_dumps)Úselfr r s úb/builddir/build/BUILD/cloudlinux-venv-1.0.12/venv/lib64/python3.11/site-packages/psycopg2/_json.pyÚ__init__z Json.__init__8 s" € ؈ŒØˆŒ ØÐ)�tœzˆŒˆˆó c ó — |t u r| S d S r )r )r Úprotos r Ú__conform__zJson.__conform__= s € Ø•IÐÐØˆKð Ðr c ó, — | |¦ « 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 r r z Json.dumpsA s € ð �{Š{˜3ÑÔÐr c ó — || _ d S r )r )r Úconns r ÚpreparezJson.prepareJ s € ؈Œ ˆ ˆ r c ó¾ — | | j ¦ « }t |¦ « }| j �| | j ¦ « | ¦ « S r )r r r r r Ú getquoted)r ÚsÚqss r r zJson.getquotedM sJ € Ø�JŠJ�t”|Ñ$Ô$ˆÝ ˜!‰_Œ_ˆØŒ:Ð!Ø�JŠJ�t”zÑ"Ô"Ð"Ø�|Š|‰~Œ~Ðr c óR — | ¦ « dd¦ « S )NÚasciiÚreplace)r Údecode)r s r Ú__str__zJson.__str__T s" € à�~Š~ÑÔ×&Ò& w° Ñ:Ô:Ð:r r ) Ú__name__Ú __module__Ú__qualname__Ú__doc__r r r r r r' © r r r r . s} € € € € € ðð ð*ð *ð *ð *ð ð ð ð ð ð ðð ð ðð ð ð;ð ;ð ;ð ;ð ;r r Fr c óÜ — |€t | |¦ « \ }}t |||| ¦ « ¬¦ « \ }}t || r| pd¦ « |�t || r| pd¦ « ||fS )a Create 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_jsonr9 Y s� € ð2 €{Ý'¨°dÑ;Ô;‰ˆˆYå.؈Y˜e¨$¯*ª*©,¬,ð8ñ 8ô 8�O€Dˆ)õ �$˜H˜Ð5¨Ð=¸Ñ>Ô>Ð>àÐÝ�i X Ð!>°,Ð!FÀ$ÑGÔGÐGà�ˆ?Ðr c ó> — t | ||t t ¬¦ « 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()`. )r3 r4 r. r5 r6 )r9 ÚJSON_OIDÚ JSONARRAY_OID©r3 r4 r. s r Úregister_default_jsonr> € s&