403Webshell
Server IP : 192.158.238.246  /  Your IP : 18.117.216.191
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib64/python3.7/site-packages/psycopg2/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib64/python3.7/site-packages/psycopg2/__pycache__/_range.cpython-37.pyc
B

*��]E�@s�dZddlZddlmZmZddlmZmZmZddlm	Z	m
Z
mZddlm
Z
Gdd�de�Zd0d
d�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Zeee�eeedddd�Ze��eeeddd d�Ze��eeed!d"d#d�Ze��ed$ed%d&d'd�Ze��ed(ed)d*d+d�Ze��ed,ed-d.d/d�Ze��dS)1z1Implementation of the Range type and adaptation

�N)�ProgrammingError�InterfaceError)�	ISQLQuote�adapt�register_adapter)�new_type�new_array_type�
register_type)�string_typesc@s�eZdZdZdZd2dd�Zdd	�Zd
d�Zedd
��Z	edd��Z
edd��Zedd��Zedd��Z
edd��Zedd��Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�ZdS)3�Rangea�Python representation for a PostgreSQL |range|_ type.

    :param lower: lower bound for the range. `!None` means unbound
    :param upper: upper bound for the range. `!None` means unbound
    :param bounds: one of the literal strings ``()``, ``[)``, ``(]``, ``[]``,
        representing whether the lower or upper bounds are included
    :param empty: if `!True`, the range is empty

    )�_lower�_upper�_boundsN�[)FcCsB|s,|dkrtd|��||_||_||_nd|_|_|_dS)N)z[)z(]z()z[]zbound flags not valid: %r)�
ValueErrorrr
r)�self�lower�upper�bounds�empty�r�B/opt/alt/python37/lib64/python3.7/site-packages/psycopg2/_range.py�__init__/szRange.__init__cCs4|jdkrd|jjSd|jj|j|j|jfSdS)Nz%s(empty=True)z%s(%r, %r, %r))r�	__class__�__name__rr
)rrrr�__repr__:s
zRange.__repr__cCs>|jdkrdS|jdt|j�dt|j�|jdg}d�|�S)Nrrz, ��)r�strrr
�join)r�itemsrrr�__str__As
z
Range.__str__cCs|jS)z:The lower bound of the range. `!None` if empty or unbound.)r)rrrrrNszRange.lowercCs|jS)z:The upper bound of the range. `!None` if empty or unbound.)r
)rrrrrSszRange.uppercCs
|jdkS)z`!True` if the range is empty.N)r)rrrr�isemptyXsz
Range.isemptycCs|jdkrdS|jdkS)z0`!True` if the range doesn't have a lower bound.NF)rr)rrrr�	lower_inf]s
zRange.lower_infcCs|jdkrdS|jdkS)z1`!True` if the range doesn't have an upper bound.NF)rr
)rrrr�	upper_infds
zRange.upper_infcCs&|jdks|jdkrdS|jddkS)z4`!True` if the lower bound is included in the range.NFr�[)rr)rrrr�	lower_inckszRange.lower_inccCs&|jdks|jdkrdS|jddkS)z4`!True` if the upper bound is included in the range.NFr�])rr
)rrrr�	upper_incrszRange.upper_inccCs~|jdkrdS|jdk	rD|jddkr6||jkrDdSn||jkrDdS|jdk	rz|jddkrl||jkrzdSn||jkrzdSdS)NFrr%rr'T)rrr
)r�xrrr�__contains__ys






zRange.__contains__cCs
|jdk	S)N)r)rrrr�__bool__�szRange.__bool__cCst|��|�S)N)�typer+)rrrr�__nonzero__�szRange.__nonzero__cCs2t|t�sdS|j|jko0|j|jko0|j|jkS)NF)�
isinstancerrr
r)r�otherrrr�__eq__�s

zRange.__eq__cCs|�|�S)N)r0)rr/rrr�__ne__�szRange.__ne__cCst|j|j|jf�S)N)�hashrr
r)rrrr�__hash__�szRange.__hash__cCs^t|t�stSxJdD]B}t||�}t||�}||kr6q|dkrBdS|dkrNdS||kSqWdS)N)rr
rTF)r.r�NotImplemented�getattr)rr/�attrZ
self_valueZother_valuerrr�__lt__�s



zRange.__lt__cCs||krdS|�|�SdS)NT)r7)rr/rrr�__le__�szRange.__le__cCst|t�r|�|�StSdS)N)r.rr7r4)rr/rrr�__gt__�s

zRange.__gt__cCs||krdS|�|�SdS)NT)r9)rr/rrr�__ge__�szRange.__ge__cs�fdd��jD�S)Ncs"i|]}t�|�rt�|�|�qSr)�hasattrr5)�.0�slot)rrr�
<dictcomp>�sz&Range.__getstate__.<locals>.<dictcomp>)�	__slots__)rr)rr�__getstate__�s
zRange.__getstate__cCs&x |��D]\}}t|||�q
WdS)N)r �setattr)r�stater=�valuerrr�__setstate__�szRange.__setstate__)NNrF)r�
__module__�__qualname__�__doc__r?rrr!�propertyrrr"r#r$r&r(r*r+r-r0r1r3r7r8r9r:r@rDrrrrr#s0	

rFcCs&t�|||�}|�|r|pd�|S)a�Create and register an adapter and the typecasters to convert between
    a PostgreSQL |range|_ type and a PostgreSQL `Range` subclass.

    :param pgrange: the name of the PostgreSQL |range| type. Can be
        schema-qualified
    :param pyrange: a `Range` strict subclass, or just a name to give to a new
        class
    :param conn_or_curs: a connection or cursor used to find the oid of the
        range and its subtype; the typecaster is registered in a scope limited
        to this object, unless *globally* is set to `!True`
    :param globally: if `!False` (default) register the typecaster only on
        *conn_or_curs*, otherwise register it globally
    :return: `RangeCaster` instance responsible for the conversion

    If a string is passed to *pyrange*, a new `Range` subclass is created
    with such name and will be available as the `~RangeCaster.range` attribute
    of the returned `RangeCaster` object.

    The function queries the database on *conn_or_curs* to inspect the
    *pgrange* type and raises `~psycopg2.ProgrammingError` if the type is not
    found.  If querying the database is not advisable, use directly the
    `RangeCaster` class and register the adapter and typecasters using the
    provided functions.

    N)�RangeCaster�_from_db�	_register)�pgrange�pyrange�conn_or_cursZgloballyZcasterrrr�register_range�srOc@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)�RangeAdapterz�`ISQLQuote` adapter for `Range` subclasses.

    This is an abstract class: concrete classes must set a `name` class
    attribute or override `getquoted()`.
    NcCs
||_dS)N)�adapted)rrQrrrr�szRangeAdapter.__init__cCs|jtkr|SdS)N)Z_protor)r�protorrr�__conform__�s
zRangeAdapter.__conform__cCs
||_dS)N)�_conn)r�connrrr�prepareszRangeAdapter.preparecCs�|jdkrtd��|j}|jr.d|j�d�S|jdk	rbt|j�}t|d�rX|�|j	�|�
�}nd}|jdk	r�t|j�}t|d�r�|�|j	�|�
�}nd}|j�d�d|d|d|j�d�d	S)
NzMRangeAdapter must be subclassed overriding its name or the getquoted() methods	'empty'::�utf8rVsNULL�(s, s, 's'))
�name�NotImplementedErrorrQr"�encoderrr;rVrT�	getquotedrr)r�r�arrrrrr\s&








zRangeAdapter.getquoted)	rrErFrGrYrrSrVr\rrrrrP�srPc@sZeZdZdZddd�Zdd�Zedd��Ze�	d	ej
�Ze�	d
�Zddd�Z
dd
d�ZdS)rIa	Helper class to convert between `Range` and PostgreSQL range types.

    Objects of this class are usually created by `register_range()`. Manual
    creation could be useful if querying the database is not advisable: in
    this case the oids must be provided.
    NcCs`||_|�||�|jjp"|jjj}t|f||j�|_|dk	rVt	|f|d|j�|_
nd|_
dS)N�ARRAY)�subtype_oid�_create_ranges�adapterrYrrr�parse�
typecasterr�array_typecaster)rrLrM�oidr`�	array_oidrYrrrr(szRangeCaster.__init__cCs�d|_t|t�r*t|tfi�|_||j_n2yt|t�rD|tk	rD||_Wntk
rZYnX|jdkrntd��d|_y6t|t�r�t|t	fi�|_t|t	�r�|t	k	r�||_Wntk
r�YnX|jdkr�td��dS)z0Create Range and RangeAdapter classes if needed.Nz:pgrange must be a string or a RangeAdapter strict subclassz1pyrange must be a type or a Range strict subclass)
rbr.r
r,rPrY�
issubclass�	TypeError�ranger)rrLrMrrrra6s0







zRangeCaster._create_rangescCs�ddlm}ddlm}||�\}}|jjdkr@td|jj��|j}d|kr`|�dd�\}	}
n|}
d}	y|�	d	|
|	f�Wn$tk
r�|j
s�|���Yn X|��}||kr�|j
s�|��|s�td
|��|\}}
}t
||||
|d�S)z|Return a `RangeCaster` instance for the type *pgrange*.

        Raise `ProgrammingError` if the type is not found.
        r)�STATUS_IN_TRANSACTION)�_solve_conn_cursiX`z'range types not available in version %s�.r�publicz�select rngtypid, rngsubtype,
    (select typarray from pg_type where oid = rngtypid)
from pg_range r
join pg_type t on t.oid = rngtypid
join pg_namespace ns on ns.oid = typnamespace
where typname = %s and ns.nspname = %s;
zPostgreSQL type '%s' not found)rfr`rg)�psycopg2.extensionsrkZpsycopg2.extrasrl�infoZserver_versionr�status�split�executeZ
autocommitZrollbackZfetchonerI)rrYrMrNrkrlrUZcursZconn_statusZschemaZtnameZrecr,�subtype�arrayrrrrJYs8

zRangeCaster._from_dba]
        ( \(|\[ )                   # lower bound flag
        (?:                         # lower bound:
          " ( (?: [^"] | "")* ) "   #   - a quoted string
          | ( [^",]+ )              #   - or an unquoted string
        )?                          #   - or empty (not catched)
        ,
        (?:                         # upper bound:
          " ( (?: [^"] | "")* ) "   #   - a quoted string
          | ( [^"\)\]]+ )           #   - or an unquoted string
        )?                          #   - or empty (not catched)
        ( \)|\] )                   # upper bound flag
        z	(["\\])\1cCs�|dkrdS|dkr |jdd�S|j�|�}|dkr@td|��|�d�}|dkrr|�d�}|dk	rr|j�d|�}|�d�}|dkr�|�d	�}|dk	r�|j�d|�}|dk	r�|�|j|�}|�|j|�}|�d
�|�d�}|�|||�S)NrT)rzfailed to parse range: '%s'��z\1��r�)	rj�	_re_range�matchr�group�_re_undouble�sub�castr`)r�s�cur�mrrrrrrrc�s,



zRangeCaster.parsecCs4t|j|�|jdk	r"t|j|�t|j|j�dS)N)r	rdrerrjrb)rZscoperrrrK�s
zRangeCaster._register)N)N)N)rrErFrGrra�classmethodrJ�re�compile�VERBOSEr{r~rcrKrrrrrI!s
#8


rIc@seZdZdZdS)�NumericRangez�A `Range` suitable to pass Python numeric types to a PostgreSQL range.

    PostgreSQL types :sql:`int4range`, :sql:`int8range`, :sql:`numrange` are
    casted into `!NumericRange` instances.
    N)rrErFrGrrrrr��sr�c@seZdZdZdS)�	DateRangez#Represents :sql:`daterange` values.N)rrErFrGrrrrr��sr�c@seZdZdZdS)�
DateTimeRangez!Represents :sql:`tsrange` values.N)rrErFrGrrrrr��sr�c@seZdZdZdS)�DateTimeTZRangez#Represents :sql:`tstzrange` values.N)rrErFrGrrrrr��sr�c@seZdZdZdd�ZdS)�NumberRangeAdapterz1Adapt a range if the subtype doesn't need quotes.cCsr|j}|jrdS|js,t|j����d�}nd}|jsLt|j����d�}nd}d|j	d|||j	df�
d�S)Ns'empty'�asciirz'%s%s,%s%s'rr)rQr"r#rrr\�decoder$rrr[)rr]rrrrrr\�szNumberRangeAdapter.getquotedN)rrErFrGr\rrrrr��sr�i@�iA)rfr`rgiV�iWiBi�iCZ	daterangeiHi:iIZtsrangeiDiZiEZ	tstzrangeiFi�iG)F)rGr�Zpsycopg2._psycopgrrrorrrrrr	Zpsycopg2.compatr
�objectrrOrPrIr�r�r�r�r�Zint4range_casterrKZint8range_casterZnumrange_casterZdaterange_casterZtsrange_casterZtstzrange_casterrrrr�<module>sF0
0(	



Youez - 2016 - github.com/yon3zu
LinuXploit