+
    }¯³jñ  ã                   óŒ   € R t ^ RIt^ RIHtHt ^ RIHtHtHt ^rt^Çt	Rt
Rt ! R R4      tRR ltRR	 ltRR
 ltRR ltRR ltR# )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_typeiÚ  iß  c                   óL   a € ] tR t^.t o RtR
R ltR tR tR tR t	R t
R	tV tR# )ÚJsonzø
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                ó^   € Wn         R V n        T;'       g    \        P                  V n        R # ©N)ÚadaptedÚ_connÚjsonÚdumpsÚ_dumps)Úselfr   r   s   &&&ÚO/home/luca/screen-checking/.venv/lib/python3.14/site-packages/psycopg2/_json.pyÚ__init__ÚJson.__init__8   s!   € ØŒØˆŒ
Ø×)Ð)œtŸz™zˆŽó    c                ó   € V\         J d   V # R # r
   )r   )r   Úprotos   &&r   Ú__conform__ÚJson.__conform__=   s   € Ø”IÓØˆKñ r   c                ó$   € V P                  V4      # )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   Ú
Json.dumpsA   s   € ð �{‰{˜3ÓÐr   c                ó   € Wn         R # r
   )r   )r   Úconns   &&r   ÚprepareÚJson.prepareJ   s   € ØŽ
r   c                óÀ   € V P                  V P                  4      p\        V4      pV P                  e   VP	                  V P                  4       VP                  4       # r
   )r   r   r   r   r   Ú	getquoted)r   ÚsÚqss   &  r   r!   ÚJson.getquotedM   sC   € Ø�J‰J�t—|‘|Ó$ˆÜ˜!‹_ˆØ�:‰:Ò!Ø�J‰J�t—z‘zÔ"Ø�|‰|‹~Ðr   c                óB   € V P                  4       P                  R R4      # )ÚasciiÚreplace)r!   Údecode)r   s   &r   Ú__str__ÚJson.__str__T   s   € à�~‰~Ó×&Ñ& w°	Ó:Ð:r   )r   r   r   r
   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r   r!   r)   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r   r   r   .   s-   ø‡ € ñô*ò
ò òò÷;ð ;r   r   c                óü   € Vf   \        W4      w  r4\        W4W%P                  4       R7      w  rg\        Ya'       * ;'       d    T ;'       g    R4       Ve%   \        Yq'       * ;'       d    T ;'       g    R4       Wg3# )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Úgloballyr4   ÚoidÚ	array_oidr5   ÚJSONÚ	JSONARRAYs   &&&&&&  r   Úregister_jsonr?   Y   sp   € ð2 ‚{Ü'¨Ó;‰ˆä.Ø˜e¯*©*«,ô8�O€Dô �$œ×5Ð5¨×=Ð=¸Ô>àÒÜ�i¤×!>Ð!>°,×!FÐ!FÀ$ÔGàˆ?Ðr   c                ó0   € \        WV\        \        R7      # )ac  
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()`.
)r9   r:   r4   r;   r<   )r?   ÚJSON_OIDÚJSONARRAY_OID©r9   r:   r4   s   &&&r   Úregister_default_jsonrD   €   s   € ô  lØœ¬]ô<ð <r   c           	     ó2   € \        WV\        \        RR7      # )aF  
Create and register :sql:`jsonb` typecasters for PostgreSQL 9.4 and following.

As in `register_default_json()`, the function allows to register a
customized *loads* function for the :sql:`jsonb` type at its known oid for
PostgreSQL 9.4 and following versions.  All the parameters have the same
meaning of `register_json()`.
Újsonb)r9   r:   r4   r;   r<   r5   )r?   Ú	JSONB_OIDÚJSONBARRAY_OIDrC   s   &&&r   Úregister_default_jsonbrI   �   s   € ô  lØœ¬nÀ7ôLð Lr   c                óŒ   a€ Sf   \         P                  oV3R lp\        V 3W44      pVe   \        V3V R2V4      pWV3# RpWV3# )z&Create typecasters for json data type.Nc                 ó    <€ V f   R # S! V 4      # r
   © )r"   Úcurr4   s   &&€r   Útypecast_jsonÚ/_create_json_typecasters.<locals>.typecast_jsonŸ   s   ø€ ØŠ9ÙÙ�Q‹xˆr   ÚARRAY)r   r4   r   r   )r;   r<   r4   r5   rN   r=   r>   s   &&f&   r   r7   r7   š   s[   ø€ à‚}Ü—
‘
ˆõô
 �S�G˜TÓ1€DØÒÜ" I =°T°F¸%°.À$ÓGˆ	ð ˆ?Ðð ˆ	àˆ?Ðr   c                 ó€  € ^ RI Hp ^ RIHp V! V 4      w  rEVP                  pVP
                  P                  R8¬  ;'       d    R;'       g    RpVP                  RV,          V34       VP                  4       pWb8w  d#   VP                  '       g   VP                  4        V'       g   VP                  V R24      hV# )é    )Ú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.extensionsrS   Úpsycopg2.extrasrT   ÚstatusÚinfoÚserver_versionÚexecuteÚfetchoneÚ
autocommitÚrollbackÚProgrammingError)	r9   r5   rS   rT   r   ÚcursÚconn_statusrU   Úrs	   &&       r   r6   r6   ­   sª   € å9Ý0á! ,Ó/�J€Dð —+‘+€Kð �y‰y×'Ñ'¨5Ñ0×?Ð?°Z×IÐIÀ6€Hð 	‡L�LØ@Ø
õ	Ø�Gôð 	�‰‹€Að Ô+°D·O·O°OØ�‰ŒçØ×#Ñ# t fÐ,@Ð$AÓBÐBà€Hr   )NFNNNr   )NFN)Nr=   )r   )r/   r   Úpsycopg2._psycopgr   r   r   r   r   rA   rB   rG   rH   r   r?   rD   rI   r7   r6   rL   r   r   Ú<module>re      sV   ðñó< ç 5ß EÑ Eð €Ø€ð €	Ø€÷(;ñ (;ôV$ôN
<ô
Lôö&r   