%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/_range.pyc

�
�ac	@s?dZddlZddlmZmZddlmZmZmZddlm	Z	m
Z
mZddlm
Z
defd��YZed	�Zd
efd��YZdefd
��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZeee�eeedddddd�Zej�eeedddddd �Zej�eeedd!dd"dd#�Zej�ed$edd%dd&dd'�Zej�ed(edd)dd*dd+�Zej�ed,edd-dd.dd/�Zej�dS(0s1Implementation of the Range type and adaptation

i����N(tProgrammingErrortInterfaceError(t	ISQLQuotetadapttregister_adapter(tnew_typetnew_array_typet
register_type(tstring_typestRangecBseZdZdZddded�Zd�Zd�Ze	d��Z
e	d	��Ze	d
��Ze	d��Z
e	d��Ze	d
��Ze	d��Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(s�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

    t_lowert_uppert_boundss[)cCs^|sC|dkr%td|��n||_||_||_nd|_|_|_dS(Ns[)s(]s()s[]sbound flags not valid: %r(s[)s(]s()s[](t
ValueErrorR
RRtNone(tselftlowertuppertboundstempty((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt__init__/s		cCsD|jdkrd|jjSd|jj|j|j|jfSdS(Ns%s(empty=True)s%s(%r, %r, %r)(RRt	__class__t__name__R
R(R((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt__repr__:scCsU|jdkrdS|jdt|j�dt|j�|jdg}dj|�S(NRis, it(RRtstrR
Rtjoin(Rtitems((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt__str__As
cCs|jS(s:The lower bound of the range. `!None` if empty or unbound.(R
(R((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyRNscCs|jS(s:The upper bound of the range. `!None` if empty or unbound.(R(R((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyRSscCs
|jdkS(s`!True` if the range is empty.N(RR(R((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pytisemptyXscCs |jdkrtS|jdkS(s0`!True` if the range doesn't have a lower bound.N(RRtFalseR
(R((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt	lower_inf]scCs |jdkrtS|jdkS(s1`!True` if the range doesn't have an upper bound.N(RRRR(R((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt	upper_infdscCs3|jdks|jdkr"tS|jddkS(s4`!True` if the lower bound is included in the range.it[N(RRR
R(R((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt	lower_inckscCs3|jdks|jdkr"tS|jddkS(s4`!True` if the upper bound is included in the range.it]N(RRRR(R((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt	upper_incrscCs�|jdkrtS|jdk	ra|jddkrK||jkr^tSqa||jkratSn|jdk	r�|jddkr�||jkr�tSq�||jkr�tSntS(NiR!iR#(RRRR
RtTrue(Rtx((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt__contains__yscCs
|jdk	S(N(RR(R((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt__bool__�scCst|�j|�S(N(ttypeR((R((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt__nonzero__�scCsGt|t�stS|j|jkoF|j|jkoF|j|jkS(N(t
isinstanceR	RR
RR(Rtother((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt__eq__�s
cCs|j|�S(N(R-(RR,((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt__ne__�scCst|j|j|jf�S(N(thashR
RR(R((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt__hash__�scCst|t�stSxedD]]}t||�}t||�}||krMq|dkr]tS|dkrmtS||kSqWtS(NR
RR(R
RR(R+R	tNotImplementedtgetattrRR%R(RR,tattrt
self_valuetother_value((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt__lt__�s
cCs!||krtS|j|�SdS(N(R%R6(RR,((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt__le__�scCs$t|t�r|j|�StSdS(N(R+R	R6R1(RR,((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt__gt__�s
cCs!||krtS|j|�SdS(N(R%R8(RR,((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt__ge__�scs�fd��jD�S(Ncs1i|]'}t�|�rt�|�|�qS((thasattrR2(t.0tslot(R(sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pys
<dictcomp>�s	(t	__slots__(R((RsF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt__getstate__�scCs1x*|j�D]\}}t|||�q
WdS(N(Rtsetattr(RtstateR<tvalue((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt__setstate__�s(R
RRN(Rt
__module__t__doc__R=RRRRRtpropertyRRRRR R"R$R'R(R*R-R.R0R6R7R8R9R>RB(((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyR	#s0			
											cCs3tj|||�}|j|r(|p+d�|S(s�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(tRangeCastert_from_dbt	_registerR(tpgrangetpyrangetconn_or_curstgloballytcaster((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pytregister_range�stRangeAdaptercBs8eZdZdZd�Zd�Zd�Zd�ZRS(s�`ISQLQuote` adapter for `Range` subclasses.

    This is an abstract class: concrete classes must set a `name` class
    attribute or override `getquoted()`.
    cCs
||_dS(N(tadapted(RRP((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyR�scCs|jtkr|SdS(N(t_protoR(Rtproto((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt__conform__�scCs
||_dS(N(t_conn(Rtconn((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pytpreparescCs&|jdkrtd��n|j}|jrDd|jjd�S|jdk	r�t|j�}t|d�r�|j	|j
�n|j�}nd}|jdk	r�t|j�}t|d�r�|j	|j
�n|j�}nd}|jjd�d|d|d|j
jd�d	S(
NsMRangeAdapter must be subclassed overriding its name or the getquoted() methods	'empty'::tutf8RVtNULLt(s, s, 's')(tnameRtNotImplementedErrorRPRtencodeRRR:RVRTt	getquotedRR(RtrtaRR((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyR]s&		N(	RRCRDRRZRRSRVR](((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyRO�s			RFcBsneZdZdd�Zd�Zed��Zej	dej
�Zej	d�Zdd�Z
dd�ZRS(	s	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.
    cCs�||_|j||�|jjp1|jjj}t|f||j�|_|dk	r}t
|f|d|j�|_n	d|_dS(NtARRAY(tsubtype_oidt_create_rangestadapterRZRRRtparset
typecasterRRtarray_typecaster(RRIRJtoidRat	array_oidRZ((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyR(s	cCs0d|_t|t�r?t|tfi�|_||j_n?y+t|t�ri|tk	ri||_nWntk
r}nX|jdkr�td��nd|_	yUt|t�r�t|t
fi�|_	nt|t
�r�|t
k	r�||_	nWntk
r
nX|j	dkr,td��ndS(s0Create Range and RangeAdapter classes if needed.s:pgrange must be a string or a RangeAdapter strict subclasss1pyrange must be a type or a Range strict subclassN(RRcR+RR)RORZt
issubclasst	TypeErrortrangeR	(RRIRJ((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyRb6s0	
	
c	CsVddlm}ddlm}||�\}}|jjdkr]td|jj��n|j}d|kr�|jdd�\}	}
n|}
d}	y|j	d	|
|	f�Wn*tk
r�|j
s�|j�n�n0X|j�}||kr|j
r|j�n|s(td
|��n|\}}
}t
||d|d|
d
|�S(s|Return a `RangeCaster` instance for the type *pgrange*.

        Raise `ProgrammingError` if the type is not found.
        i����(tSTATUS_IN_TRANSACTION(t_solve_conn_cursiX`s'range types not available in version %st.itpublics�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;
sPostgreSQL type '%s' not foundRgRaRh(tpsycopg2.extensionsRltpsycopg2.extrasRmtinfotserver_versionRtstatustsplittexecutet
autocommittrollbacktfetchoneRF(RRZRJRKRlRmRUtcurstconn_statustschemattnametrecR)tsubtypetarray((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyRGYs8	
	


s]
        ( \(|\[ )                   # 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
        s	(["\\])\1cCsg|dkrdS|dkr,|jdt�S|jj|�}|dkr]td|��n|jd�}|dkr�|jd�}|dk	r�|jjd|�}q�n|jd�}|dkr�|jd�}|dk	r�|jjd|�}q�n|dk	r8|j	|j
|�}|j	|j
|�}n|jd�|jd	�}|j|||�S(
NRsfailed to parse range: '%s'iis\1iiii(RRkR%t	_re_rangetmatchRtgroupt_re_undoubletsubtcastRa(RtstcurtmRRR((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyRd�s,cCsIt|j|�|jdk	r2t|j|�nt|j|j�dS(N(RReRfRRRkRc(Rtscope((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyRH�sN(RRCRDRRRbtclassmethodRGtretcompiletVERBOSER�R�RdRH(((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyRF!s	#8tNumericRangecBseZdZRS(s�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.
    (RRCRD(((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyR��st	DateRangecBseZdZRS(s#Represents :sql:`daterange` values.(RRCRD(((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyR��st
DateTimeRangecBseZdZRS(s!Represents :sql:`tsrange` values.(RRCRD(((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyR��stDateTimeTZRangecBseZdZRS(s#Represents :sql:`tstzrange` values.(RRCRD(((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyR��stNumberRangeAdaptercBseZdZd�ZRS(s1Adapt a range if the subtype doesn't need quotes.cCs�|j}|jrdS|js@t|j�j�jd�}nd}|jspt|j�j�jd�}nd}d|j	d|||j	dfj
d�S(Ns'empty'tasciiRs'%s%s,%s%s'ii(RPRRRRR]tdecodeR RRR\(RR^RR((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyR]�s			!	!(RRCRDR](((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyR��sRgi@RaiRhiAiViiWiBi�iCt	daterangeiHi:iIttsrangeiDiZiEt	tstzrangeiFi�iG( RDR�tpsycopg2._psycopgRRRpRRRRRRtpsycopg2.compatRtobjectR	RRNRORFR�R�R�R�R�tint4range_casterRHtint8range_castertnumrange_castertdaterange_casterttsrange_casterttstzrange_caster(((sF/opt/plesk/python/2.7/lib64/python2.7/site-packages/psycopg2/_range.pyt<module>sB�0�	








Zerion Mini Shell 1.0