%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/
Upload File :
Create Path :
Current File : //opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyc

�
�ac@s�dZddlZddlmZmZddlmZmZmZddlm	Z	dZ
dZdZd	Z
d
efd��YZdeddddd
�Zdedd�Zdedd�Zddd�Zdd�ZdS(s�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.
i����N(t	ISQLQuotetQuotedString(tnew_typetnew_array_typet
register_type(tPY2iri�i�i�tJsoncBsYeZdZdd�Zd�Zd�Zd�Zd�Ze	rNd�Z
n	d�Z
RS(	s
    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.

    cCs(||_d|_|ptj|_dS(N(tadaptedtNonet_conntjsontdumpst_dumps(tselfRR((sE/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyt__init__8s		cCs|tkr|SdS(N(R(R
tproto((sE/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyt__conform__=scCs
|j|�S(s�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
tobj((sE/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyRAscCs
||_dS(N(R	(R
tconn((sE/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pytprepareJscCsJ|j|j�}t|�}|jdk	r@|j|j�n|j�S(N(RRRR	RRt	getquoted(R
tstqs((sE/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyRMs
cCs
|j�S(N(R(R
((sE/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyt__str__UscCs|j�jdd�S(Ntasciitreplace(Rtdecode(R
((sE/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyRXsN(t__name__t
__module__t__doc__RRRRRRRR(((sE/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyR.s						R
cCs�|dkr$t||�\}}nt||d|d|j��\}}t||r^|pad�|dk	r�t||r�|p�d�n||fS(sCreate 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.

    tloadstnameN(Rt_get_json_oidst_create_json_typecasterstupperR(tconn_or_curstgloballyRtoidt	array_oidRtJSONt	JSONARRAY((sE/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyt
register_json]s$cCs%td|d|d|dtdt�S(s{
    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$RR%R&(R)tJSON_OIDt
JSONARRAY_OID(R#R$R((sE/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pytregister_default_json�s	c
Cs+td|d|d|dtdtdd�S(s^
    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()`.
    R#R$RR%R&Rtjsonb(R)t	JSONB_OIDtJSONBARRAY_OID(R#R$R((sE/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pytregister_default_jsonb�s	R'cst�dkrtj�n�fd�}t|f||�}|dk	rdt|fd||�}nd}||fS(s&Create typecasters for json data type.cs|dkrdS�|�S(N(R(Rtcur(R(sE/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyt
typecast_json�ss%sARRAYN(RR
RRR(R%R&RRR2R'R(((RsE/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyR!�sc	Cs�ddlm}ddlm}||�\}}|j}|jjdkrSdpVd}|jd||f�|j�}||kr�|j	r�|j
�n|s�|jd|��n|S(	Ni����(tSTATUS_IN_TRANSACTION(t_solve_conn_cursi�9ttyparraytNULLs6SELECT t.oid, %s FROM pg_type t WHERE t.typname = %%s;s%s data type not found(tpsycopg2.extensionsR3tpsycopg2.extrasR4tstatustinfotserver_versiontexecutetfetchonet
autocommittrollbacktProgrammingError(	R#RR3R4Rtcurstconn_statusR5tr((sE/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyR �s	
(RR
tpsycopg2._psycopgRRRRRtpsycopg2.compatRR*R+R.R/tobjectRRtFalseR)R,R0R!R (((sE/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_json.pyt<module>s/	&



Zerion Mini Shell 1.0