%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python27/lib/python2.7/site-packages/paste/util/
Upload File :
Create Path :
Current File : //opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyc

�
b�Nc@s�dZdZdZdZdZdefd��YZee�Zee	�Z
defd��YZed	kr�ed
dfd�Z
ed
df�Zed
dfdd
dfdddd�Ze
GHe
d@GHe
dBGHe
d
dfAGHe
dGHde
kGHe
je
�GHeje
�GHe
je
�GHeje
�GHxe
D]ZeGHq8We
j�GHe
ekGHe
ekGHe
ekGHee
�GHee�GHee
�GHe
j�GHndS(stImmutable integer set type.

Integer set class.

Copyright (C) 2006, Heiko Wundram.
Released under the MIT license.
s Heiko Wundram <me@modelnine.org>s0.2t6s
2006-01-20t	_InfinitycBs_eZdZdgZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
s0Internal type used to represent infinity values.t_negcCs
||_dS(N(R(tselftneg((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt__init__scCs<t|tttf�stS|jo;t|t�o:|jS(N(t
isinstancetinttlongRtNotImplementedR(Rtvalue((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt__lt__s	cCs#t|tttf�stS|jS(N(RRRRR	R(RR
((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt__le__$scCs=t|tttf�stS|jp;t|t�o;|jS(N(RRRRR	R(RR
((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt__gt__)s	cCs$t|tttf�stS|jS(N(RRRRR	R(RR
((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt__ge__/scCs;t|tttf�stSt|t�o:|j|jkS(N(RRRRR	R(RR
((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt__eq__4scCs<t|tttf�stSt|t�p;|j|jkS(N(RRRRR	R(RR
((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt__ne__9scCsdS(NtNone((R((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt__repr__>s(t__name__t
__module__t__doc__t	__slots__RRRR
RRRR(((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRs								tIntSetcBs�eZdZddddgZd�Zeed�Zd�Zd�Z	dJd	�Zed
ddd
��Zedddd��Z
edddd��Zedddd��Zedddd��Zedddd��Zedddd��Zedddd��Zedddd��Zed dd!d"��Zed#dd!d$��Zed%dd!d&��Zed'd(d)d*��Zed+d(d,d-��Zed.d(d/d0�d1��Zed2d(d)d3��Zed4d(d5d6�d7��Zed8d(d9d:�d;��Zed<d(d=d>��Zed?d(d@dA�dB��Z[dC�Z e Z!dD�Z"dE�Z#dF�Z$dG�Z%dH�Z&dI�Z'RS(KsvInteger set class with efficient storage in a RLE format of ranges.
    Supports minus and plus infinity in the range.t_rangest_mint_maxt_hashcOs�t|�dkr~t|dt�r~|r:td��n|dj|_|dj|_|dj|_|dj|_dSg|_|jdt	�|_|jdt
�|_|jdkr�t	|_n|jdkr�t
|_n|r�td��nt|jtt
f�p |jt	ks2td��nt|jtt
f�pV|jt
kshtd	��n|jt	k	r�|jt
k	r�|j|jkr�td
��nt|jtt
f�r�|jd7_nx�|D]�}t|tt
f�r||d}}n't|t�r"t|�dkr7td��n|\}}|dkr[|j}n|dkrs|j}nt|tt
f�p�|t	ks�td
��nt|tt
f�p�|t
ks�td��n|t	k	r�|t
k	r�||kr�q�nt|tt
f�r.|d7}q.ntd��||jkrCq�n||jkr^|j}n||jkrsq�n||jkr�|j}n|jj||f�q�W|j�dS(s�Initialize an integer set. The constructor accepts an unlimited
        number of arguments that may either be tuples in the form of
        (start,stop) where either start or stop may be a number or None to
        represent maximum/minimum in that direction. The range specified by
        (start,stop) is always inclusive (differing from the builtin range
        operator).

        Keyword arguments that can be passed to an integer set are min and
        max, which specify the minimum and maximum number in the set,
        respectively. You can also pass None here to represent minus or plus
        infinity, which is also the default.
        iis*No keyword arguments for copy constructor.NtmintmaxsInvalid keyword argument.sInvalid type of min argument.sInvalid type of max argument.s$Minimum is not smaller than maximum.is$Invalid tuple, must be (start,stop).sInvalid type of tuple start.sInvalid type of tuple stop.sInvalid argument.(tlenRRt
ValueErrorRRRRtpopt_MININFt_MAXINFRRRt	TypeErrorttupletappendt
_normalize(Rtargstkwargstargtstarttstop((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRRsr%	''
!!ccs�|}itd6td6}dt|�dt|�}}d\}	}
x|	|ksb|
|kr^|	|kr�|
|kr�||	d?|	d@||
d?|
d@ks�|
|kr�||	d?|	d@d|	d@}}}
|	d7}	n3||
d?|
d@d|
d@}}}
|
d7}
||krQ||kr7Pn|||ffV|}n|
||<qJW||kr|||ffVndS(Ntr1tr2iii(ii(tFalseR(RR,R-tminvaltmaxvaltcurvalt	curstatestimaxtjmaxtitjtcur_rtnewnametnewstate((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt_iterranges�s(!,)
)
	cCs�|jj�d}x�|t|j�kr�|j|d|j|ddkr�|j|ddt|j|dd|j|d�f|j|d<|j|=q|d7}qWt|j�|_t|j�|_dS(Nii(RtsortRRR$thashR(RR5((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyR&�s
&"
cCs�t|t�r||fSt|tttf�r`y||j|�fSWq�tk
r\tSXn>t|t�r�y||j|�fSWq�tk
r�tSXntS(N(	RRRRR$t	__class__R#R	tlist(Rtother((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt
__coerce__�s


csy|dkr�fd�}n-|dkr?��fd�}ntd��y
||_Wntk
rknX||_|S(sKMakes a function to match two ranges. Accepts two types: either
        'set', which defines a function which returns a set with all ranges
        matching pall (pany is ignored), or 'bool', which returns True if pall
        matches for all ranges and pany matches for any one range. doc is the
        dostring to give this function. pany may be none to ignore the any
        match.

        The predicates get a dict with two keys, 'r1', 'r2', which denote
        whether the current range is present in range1 (self) and/or range2
        (other) or none of the two, respectively.tsetcs@|j|�}|tkrtS|d}|jj|j�}t|j|j�|_t|j|j�|_g|_x�|j	|j|j|j|j�D]x\}\}}�|�r�|jr�|jdd|kr�|jdd|f|jd<q|jj
||f�q�q�Wt|j�|_t|j�|_
|S(Nii����i(R@R	R=t__new__RRRRRR:R%R$R<R(RR?tcoercedtnewsettstatesR*R+(tpall(sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pytf�s$
	" !tboolc	s�|j|�}|tkrtS|d}t|j|j�}t|j|j�}�}xT|j|j|j||�D]4\}\}}�|�s�tS|p��|�}qyW|S(Ni(	R@R	RRRRR:RR.(	RR?RCRRtfoundRER*R+(RFtpany(sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRG
s
.s#Invalid type of function to create.(Rt	func_nameR#tfunc_doc(tnamettypetdocRFRJRG((RFRJsB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt_make_function�s

	t__and__RAs&Intersection of two sets as a new set.cCs|do|dS(NR,R-((ts((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt<lambda>'st__rand__cCs|do|dS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRS*stintersectioncCs|do|dS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRS-st__or__sUnion of two sets as a new set.cCs|dp|dS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRS2st__ror__cCs|dp|dS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRS5stunioncCs|dp|dS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRS8st__sub__s$Difference of two sets as a new set.cCs|do|dS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRS=st__rsub__cCs|do|dS(NR-R,((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRS@st
differencecCs|do|dS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRSCst__xor__s.Symmetric difference of two sets as a new set.cCs|d|dAS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRSHst__rxor__cCs|d|dAS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRSKstsymmetric_differencecCs|d|dAS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRSNst__contains__RHs*Returns true if self is superset of other.cCs|dp|dS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRSSstissubsets(Returns true if self is subset of other.cCs|dp|dS(NR-R,((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRSVstistruesubsets-Returns true if self is true subset of other.cCs|dp|dS(NR-R,((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRSYscCs|do|dS(NR-R,((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRSZst
issupersetcCs|dp|dS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRS]stistruesupersets/Returns true if self is true superset of other.cCs|dp|dS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRS`scCs|do|dS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRSastoverlapss)Returns true if self overlaps with other.cCstS(N(tTrue(RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRSdscCs|do|dS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRSesRs'Returns true if self is equal to other.cCs|d|dAS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRSjsRs+Returns true if self is different to other.cCstS(N(Re(RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRSmscCs|d|dAS(NR,R-((RR((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRSnscCs�|jj|j�}|j|_|j|_g|_|j}xH|jD]=}||dkrI|jj||df�|d}qIqIW||jkr�|jj||jf�n|S(sInverse of set as a new set.ii(R=RBRRRR%(RRDtlaststoptr((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pytinversets		cCs|jS(s�Returns a hash value representing this integer set. As the set is
        always stored normalized, the hash value is guaranteed to match for
        matching ranges.(R(R((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt__hash__�scCs�|js
dS|jddtks;|jddtkrJtd��nd}x'|jD]}||d|d7}qZW|dkr�td��n|S(	s�Get length of this integer set. In case the length is larger than
        2**31 (including infinitely sized integer sets), it raises an
        OverflowError. This is due to len() restricting the size to
        0 <= len < 2**31.ii����isInfinitely sized integer set.iisInteger set bigger than 2**31.I�(RR!R"t
OverflowError(RtrlenRg((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt__len__�s	.cCss|js
dS|jddtks;|jddtkr?dSd}x'|jD]}||d|d7}qOW|S(s<Returns the length of this integer set as an integer. In case the
        length is infinite, returns -1. This function exists because of a
        limitation of the builtin len() function which expects values in
        the range 0 <= len < 2**31. Use this function in case your integer
        set might be larger.ii����i(RR!R"(RRkRg((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyR�s	.cCs
t|j�S(s<Returns true if this integer set contains at least one item.(RHR(R((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt__nonzero__�sccsg}x�|jD]�}|dtkrv|dtkrX|jddgddgf�q�|j|dddg�q|dtkr�|j|ddg�qx$t|d|d�D]}|Vq�WqW|rx;trx+|D]#}|dV|dc|d7<q�Wq�WndS(s�Iterate over all values in this integer set. Iteration always starts
        by iterating from lowest to highest over the ranges that are bounded.
        After processing these, all ranges that are unbounded (maximum 2) are
        yielded intermixed.iii����N(RR!R"textendR%txrangeRe(RtubrangesRgtvaltubrange((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt__iter__�s"
	
	cCs!g}x�|jD]�\}}t|ttf�rjt|ttf�rj||dkrj|jd|�qt|ttf�r�|jd||df�q|jd||f�qW|jtk	r�|jd|j�n|jtk	r|jd|j�nd|j	j
dj|�fS(srReturn a representation of this integer set. The representation is
        executable to get an equal integer set.is%rs(%r,%r)smin=%rsmax=%rs%s(%s)s,(RRRRR%RR!RR"R=Rtjoin(RtrvR*R+((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyR�s*N((RRRRRR!R"R:R&R@RRPRQRTRURVRWRXRYRZR[R\R]R^R_R`RaRbRcRdRRRht
__invert__RiRlRRmRsR(((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyRLs�	\		:																						
				t__main__i
iiiiRiRi(iniiN(Rt
__author__t__version__t__revision__t__date__tobjectRReR!R.R"RRtxtytzR`RaRqRhR<R(((sB/opt/alt/python27/lib/python2.7/site-packages/paste/util/intset.pyt<module>sB/��*			
	

Zerion Mini Shell 1.0