ó
    //¡jñ  ã                   óŽ   • S r SSKrSSKJrJr  SSKJrJrJr  SrSr	Sr
Sr " S	 S
5      r  SS jrSS jrSS jrSS jrSS jrg)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                   ó@   • \ rS rSrSrSS jrS rS rS rS r	S	 r
S
rg)ÚJsoné.   zø
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                 óZ   • Xl         S U l        U=(       d    [        R                  U l        g ©N)ÚadaptedÚ_connÚjsonÚdumpsÚ_dumps)Úselfr   r   s      Úg/var/www/html/health-monitoring.indevconsultancy.in/venv/lib/python3.13/site-packages/psycopg2/_json.pyÚ__init__ÚJson.__init__8   s   € ØŒØˆŒ
Ø×)œtŸz™zˆ�ó    c                 ó   • U[         L a  U $ g r   )r   )r   Úprotos     r   Ú__conform__ÚJson.__conform__=   s   € Ø”IÒØˆKð r   c                 ó$   • U R                  U5      $ )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                 ó   • Xl         g r   )r   )r   Úconns     r   ÚprepareÚJson.prepareJ   s   € Ø�
r   c                 ó¾   • U R                  U R                  5      n[        U5      nU R                  b  UR	                  U R                  5        UR                  5       $ 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   • U R                  5       R                  SS5      $ )NÚ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__© r   r   r   r   .   s%   † ñô*ò
ò òòõ;r   r   c                 óê   • Uc  [        X5      u  p4[        X4X%R                  5       S9u  pg[        Xa(       + =(       a    U =(       d    S5        Ub"  [        Xq(       + =(       a    U =(       d    S5        Xg4$ )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Úgloballyr7   ÚoidÚ	array_oidr8   ÚJSONÚ	JSONARRAYs           r   Úregister_jsonrB   Y   sd   € ð2 �{Ü'¨Ó;‰ˆä.Ø˜e¯*©*«,ñ8�O€Dô �$œ×5¨×=¸Ô>àÑÜ�i¤×!>°,×!FÀ$ÔGàˆ?Ðr   c                 ó*   • [        XU[        [        S9$ )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()`.
)r<   r=   r7   r>   r?   )rB   ÚJSON_OIDÚJSONARRAY_OID©r<   r=   r7   s      r   Úregister_default_jsonrG   €   s   € ô  lØœ¬]ñ<ð <r   c           	      ó,   • [        XU[        [        SS9$ )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)r<   r=   r7   r>   r?   r8   )rB   Ú	JSONB_OIDÚJSONBARRAY_OIDrF   s      r   Úregister_default_jsonbrL   �   s   € ô  lØœ¬nÀ7ñLð Lr   c                 óˆ   ^• Tc  [         R                  mU4S jn[        U 4X45      nUb  [        U4U S3U5      nXV4$ SnXV4$ )z&Create typecasters for json data type.Nc                 ó   >• U c  g T" U 5      $ r   r5   )r&   Úcurr7   s     €r   Útypecast_jsonÚ/_create_json_typecasters.<locals>.typecast_jsonŸ   s   ø€ Ø‰9ØÙ�Q‹xˆr   ÚARRAY)r   r7   r   r   )r>   r?   r7   r8   rP   r@   rA   s     `    r   r:   r:   š   s[   ø€ à�}Ü—
‘
ˆõô
 �S�G˜TÓ1€DØÑÜ" I =°T°F¸%°.À$ÓGˆ	ð ˆ?Ðð ˆ	àˆ?Ðr   c                 ón  • SSK Jn  SSKJn  U" U 5      u  pEUR                  nUR
                  R                  S:¬  =(       a    S=(       d    SnUR                  SU-  U45        UR                  5       nXb:w  a!  UR                  (       d  UR                  5         U(       d  UR                  U S35      eU$ )	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.extensionsrT   Úpsycopg2.extrasrU   ÚstatusÚinfoÚserver_versionÚexecuteÚfetchoneÚ
autocommitÚrollbackÚProgrammingError)	r<   r8   rT   rU   r!   ÚcursÚconn_statusrV   Úrs	            r   r9   r9   ­   s¢   € å9Ý0á! ,Ó/�J€Dð —+‘+€Kð �y‰y×'Ñ'¨5Ñ0×?°Z×IÀ6€Hð 	‡L�LØ@Ø
ñ	Ø�Gôð 	�‰‹€Að Ó+°D·O·OØ�‰ŒæØ×#Ñ# t fÐ,@Ð$AÓBÐBà€Hr   )NFNNNr   )NFN)Nr@   )r   )r3   r   Úpsycopg2._psycopgr   r   r   r   r   rD   rE   rJ   rK   r   rB   rG   rL   r:   r9   r5   r   r   Ú<module>rf      s_   ðñó< ç 5ß EÑ Eð €Ø€ð €	Ø€÷(;ñ (;ðV <@Ø17ô$ôN
<ô
Lôõ&r   