%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/227033/root/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/
Upload File :
Create Path :
Current File : //proc/227033/root/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyc

�
Tc	@s5dZddlZddlmZmZddlmZmZmZm	Z	ddlm
Z
mZmZde
fd��YZed�Zd	e
fd
��YZde
fd��YZd
efd��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(/s1Implementation of the Range type and adaptation

i����N(tProgrammingErrortInterfaceError(t	ISQLQuotetadapttregister_adaptertb(tnew_typetnew_array_typet
register_typetRangecBs�eZdZdZddded�Zd�Zed��Z	ed��Z
ed	��Zed
��Zed��Z
ed��Zed
��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((sB/opt/alt/python27/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((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyt__repr__8scCs|jS(s:The lower bound of the range. `!None` if empty or unbound.(R
(R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyR?scCs|jS(s:The upper bound of the range. `!None` if empty or unbound.(R(R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyRDscCs
|jdkS(s`!True` if the range is empty.N(RR(R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pytisemptyIscCs |jdkrtS|jdkS(s0`!True` if the range doesn't have a lower bound.N(RRtFalseR
(R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyt	lower_infNscCs |jdkrtS|jdkS(s1`!True` if the range doesn't have an upper bound.N(RRRR(R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyt	upper_infTscCs7|jdkrtS|jdkr&tS|jddkS(s4`!True` if the lower bound is included in the range.it[N(RRRR
(R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyt	lower_incZs
cCs7|jdkrtS|jdkr&tS|jddkS(s4`!True` if the upper bound is included in the range.it]N(RRRR(R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyt	upper_incas
cCs�|jdkrtS|jdk	ra|jddkrK||jkr^tSqa||jkratSn|jdk	r�|jddkr�||jkr�tSq�||jkr�tSntS(NiRiR(RRRR
RtTrue(Rtx((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyt__contains__hscCs
|jdk	S(N(RR(R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyt__nonzero__xscCsGt|t�stS|j|jkoF|j|jkoF|j|jkS(N(t
isinstanceR	RR
RR(Rtother((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyt__eq__{s
cCs|j|�S(N(R&(RR%((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyt__ne__�scCst|j|j|jf�S(N(thashR
RR(R((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyt__hash__�scCst|t�stSxedD]]}t||�}t||�}||krMq|dkr]tS|dkrmtS||kSqWtS(NR
RR(s_lowers_uppers_bounds(R$R	tNotImplementedtgetattrRR R(RR%tattrt
self_valuetother_value((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyt__lt__�s
cCs!||krtS|j|�SdS(N(R R/(RR%((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyt__le__�scCs$t|t�r|j|�StSdS(N(R$R	R/R*(RR%((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyt__gt__�s
cCs!||krtS|j|�SdS(N(R R1(RR%((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyt__ge__�s(s_lowers_uppers_boundsN(Rt
__module__t__doc__t	__slots__RRRRtpropertyRRRRRRRR"R#R&R'R)R/R0R1R2(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyR	!s(										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((sB/opt/alt/python27/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(RRA((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyR�scCs|jtkr|SdS(N(t_protoR(Rtproto((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyt__conform__�scCs
||_dS(N(t_conn(Rtconn((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pytprepare�scCs+|jdkrtd��n|j}|jrAtd|j�S|jdk	r�t|j�}t|d�r�|j	|j
�n|j�}ntd�}|jdk	r�t|j�}t|d�r�|j	|j
�n|j�}ntd�}t|jd�|td�|td|j
�S(NsMRangeAdapter must be subclassed overriding its name or the getquoted() methods	'empty'::RGtNULLt(s, s, '%s')(tnameRtNotImplementedErrorRARRRRthasattrRGREt	getquotedRR(RtrtaRR((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyRM�s&		N(	RR3R4RRJRRDRGRM(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyR@�s			R7cBsneZdZdd�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_rangestadapterRJRRRtparset
typecasterRRtarray_typecaster(RR:R;toidRQt	array_oidRJ((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyRs	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(RRSR$t
basestringttypeR@RJt
issubclasst	TypeErrortrangeR	(RR:R;((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyRRs.	
	
c
CsPddlm}ddlm}||�\}}|jdkrWtd|j��n|j}d|kr�|jdd�\}	}
n|}
d}	y|jd	|
|	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 foundRWRQRX(
tpsycopg2.extensionsR^tpsycopg2.extrasR_tserver_versionRtstatustsplittexecutet
autocommittrollbacktfetchoneR7(RRJR;R<R^R_RFtcurstconn_statustschemattnametrecRZtsubtypetarray((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyR85s8	
	


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(RR]R t	_re_rangetmatchRtgroupt_re_undoubletsubtcastRQ(RtstcurtmRRR((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyRT}s,cCsIt|j|�|jdk	r2t|j|�nt|j|j�dS(N(RRURVRRR]RS(Rtscope((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyR9�sN(RR3R4RRRRtclassmethodR8tretcompiletVERBOSERrRuRTR9(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyR7�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.
    (RR3R4(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyR��st	DateRangecBseZdZRS(s#Represents :sql:`daterange` values.(RR3R4(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyR��st
DateTimeRangecBseZdZRS(s!Represents :sql:`tsrange` values.(RR3R4(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyR��stDateTimeTZRangecBseZdZRS(s#Represents :sql:`tstzrange` values.(RR3R4(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyR��stNumberRangeAdaptercBseZdZd�ZRS(s1Adapt a range if the subtype doesn't need quotes.cCs�|j}|jrtd�S|jsFt|j�j�jd�}nd}|jsvt|j	�j�jd�}nd}d|j
d|||j
dfjd�S(Ns'empty'tasciits'%s%s,%s%s'ii(RARRRRRRMtdecodeRRRtencode(RRNRR((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyRM�s		
	!	!(RR3R4RM(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyR��sRWi@RQiRXiAiViiWiBi�iCt	daterangeiHi:iIttsrangeiDiZiEt	tstzrangeiFi�iG(R4R}tpsycopg2._psycopgRRRbRRRRRRRtobjectR	RR?R@R7R�R�R�R�R�tint4range_casterR9tint8range_castertnumrange_castertdaterange_casterttsrange_casterttstzrange_caster(((sB/opt/alt/python27/lib64/python2.7/site-packages/psycopg2/_range.pyt<module>s@"�0�








Zerion Mini Shell 1.0