mfc@sIdZddlmZmZddlZdddddd d d d d ddddddgZdZdd%dYZdd&dYZej e defdYZ dd'dYZ dd(dYZ d d)dYZd e ee fdYZej ed efdYZej ed e ee fdYZde fdYZdeefdYZdeefd YZdefd!YZd efd"YZej ede ee fd#YZej eej eej eej edefd$YZej e dS(*sAbstract Base Classes (ABCs) for collections, according to PEP 3119. DON'T USE THIS MODULE DIRECTLY! The classes here should be imported via collections; they are defined here only to alleviate certain bootstrapping issues. Unit tests are in test_collections. i(tABCMetatabstractmethodNtHashabletIterabletIteratortSizedt ContainertCallabletSett MutableSettMappingtMutableMappingt MappingViewtKeysViewt ItemsViewt ValuesViewtSequencetMutableSequencecsCy!tfd|jDSWntk r>t|SXdS(Nc3s|]}|jkVqdS(N(t__dict__(t.0tB(tattr(s/usr/lib64/python2.7/_abcoll.pys s(tanyt__mro__tAttributeErrorthasattr(tCR((Rs/usr/lib64/python2.7/_abcoll.pyt_hasattrs! cBs,eZeZedZedZRS(cCsdS(Ni((tself((s/usr/lib64/python2.7/_abcoll.pyt__hash__#scCsy|tkruy<x5|jD]*}d|jkr|jdr?tSPqqWWqutk rqt|ddrrtSquXntS(NR(RRRtTrueRtgetattrtNonetNotImplemented(tclsRR((s/usr/lib64/python2.7/_abcoll.pyt__subclasshook__'s     (t__name__t __module__Rt __metaclass__RRt classmethodR#(((s/usr/lib64/python2.7/_abcoll.pyR scBs,eZeZedZedZRS(ccsxtrdVqWdS(N(tFalseR (R((s/usr/lib64/python2.7/_abcoll.pyt__iter__:s cCs&|tkr"t|dr"tSntS(NR)(RRRR!(R"R((s/usr/lib64/python2.7/_abcoll.pyR#?s (R$R%RR&RR)R'R#(((s/usr/lib64/python2.7/_abcoll.pyR7scBs/eZedZdZedZRS(cCs tdS(sKReturn the next item from the iterator. When exhausted, raise StopIterationN(t StopIteration(R((s/usr/lib64/python2.7/_abcoll.pytnextKscCs|S(N((R((s/usr/lib64/python2.7/_abcoll.pyR)PscCs5|tkr1t|dr1t|dr1tSntS(NR+R)(RRRR!(R"R((s/usr/lib64/python2.7/_abcoll.pyR#Ss (R$R%RR+R)R'R#(((s/usr/lib64/python2.7/_abcoll.pyRIs cBs,eZeZedZedZRS(cCsdS(Ni((R((s/usr/lib64/python2.7/_abcoll.pyt__len__^scCs&|tkr"t|dr"tSntS(NR,(RRRR!(R"R((s/usr/lib64/python2.7/_abcoll.pyR#bs (R$R%RR&RR,R'R#(((s/usr/lib64/python2.7/_abcoll.pyR[scBs,eZeZedZedZRS(cCstS(N(R((Rtx((s/usr/lib64/python2.7/_abcoll.pyt __contains__mscCs&|tkr"t|dr"tSntS(NR.(RRRR!(R"R((s/usr/lib64/python2.7/_abcoll.pyR#qs (R$R%RR&RR.R'R#(((s/usr/lib64/python2.7/_abcoll.pyRjscBs,eZeZedZedZRS(cOstS(N(R((Rtargstkwds((s/usr/lib64/python2.7/_abcoll.pyt__call__|scCs&|tkr"t|dr"tSntS(NR1(RRRR!(R"R((s/usr/lib64/python2.7/_abcoll.pyR#s (R$R%RR&RR1R'R#(((s/usr/lib64/python2.7/_abcoll.pyRyscBseZdZdZdZdZdZdZdZe dZ dZ d Z d Z d Zd ZdZd ZRS(shA set is a finite, iterable container. This class provides concrete generic implementations of all methods except for __contains__, __iter__ and __len__. To override the comparisons (presumably for speed, as the semantics are fixed), all you have to do is redefine __le__ and then the other operations will automatically follow suit. cCsTt|tstSt|t|kr/tSx|D]}||kr6tSq6WtS(N(t isinstanceRR!tlenR(R(Rtothertelem((s/usr/lib64/python2.7/_abcoll.pyt__le__s  cCs8t|tstSt|t|ko7|j|S(N(R2RR!R3R6(RR4((s/usr/lib64/python2.7/_abcoll.pyt__lt__scCst|tstS||kS(N(R2RR!(RR4((s/usr/lib64/python2.7/_abcoll.pyt__gt__scCst|tstS||kS(N(R2RR!(RR4((s/usr/lib64/python2.7/_abcoll.pyt__ge__scCs8t|tstSt|t|ko7|j|S(N(R2RR!R3R6(RR4((s/usr/lib64/python2.7/_abcoll.pyt__eq__scCs ||k S(N((RR4((s/usr/lib64/python2.7/_abcoll.pyt__ne__scCs ||S(sConstruct an instance of the class from any iterable input. Must override this method if the class constructor signature does not accept an iterable for an input. ((R"tit((s/usr/lib64/python2.7/_abcoll.pyt_from_iterablescs0t|tstSjfd|DS(Nc3s!|]}|kr|VqdS(N((Rtvalue(R(s/usr/lib64/python2.7/_abcoll.pys s(R2RR!R=(RR4((Rs/usr/lib64/python2.7/_abcoll.pyt__and__scCs%x|D]}||krtSqWtS(s1Return True if two sets have a null intersection.(R(R(RR4R>((s/usr/lib64/python2.7/_abcoll.pyt isdisjoints  cCs6t|tstSd||fD}|j|S(Ncss"|]}|D] }|Vq qdS(N((Rtste((s/usr/lib64/python2.7/_abcoll.pys s(R2RR!R=(RR4tchain((s/usr/lib64/python2.7/_abcoll.pyt__or__scsQtts4tts"tS|jn|jfd|DS(Nc3s!|]}|kr|VqdS(N((RR>(R4(s/usr/lib64/python2.7/_abcoll.pys s(R2RRR!R=(RR4((R4s/usr/lib64/python2.7/_abcoll.pyt__sub__s cCsDt|ts4t|ts"tS|j|}n||||BS(N(R2RRR!R=(RR4((s/usr/lib64/python2.7/_abcoll.pyt__xor__s cCstj}d|d}t|}d|d}||M}x>|D]6}t|}|||d>AdAdN}||M}qBW|dd}||M}||kr||d8}n|d krd }n|S( s+Compute the hash value of a set. Note that we don't define __hash__: not all sets are hashable. But if you define a hashable set type, its __hash__ should call this function. This must be compatible __eq__. All sets ought to compare equal if they contain the same elements, regardless of how they are implemented, and regardless of the order of the elements; so there's not much freedom for __eq__ or __hash__. We match the algorithm used by the built-in frozenset type. iiiMriiM[I4?i i6ii8#(tsystmaxintR3thash(RtMAXtMASKtnthR-thx((s/usr/lib64/python2.7/_abcoll.pyt_hashs          N(R$R%t__doc__R6R7R8R9R:R;R'R=R?R@RDRERFR RRO(((s/usr/lib64/python2.7/_abcoll.pyRs           cBskeZdZedZedZdZdZdZdZ dZ dZ d Z RS( sA mutable set is a finite, iterable container. This class provides concrete generic implementations of all methods except for __contains__, __iter__, __len__, add(), and discard(). To override the comparisons (presumably for speed, as the semantics are fixed), all you have to do is redefine __le__ and then the other operations will automatically follow suit. cCs tdS(sAdd an element.N(tNotImplementedError(RR>((s/usr/lib64/python2.7/_abcoll.pytaddscCs tdS(s8Remove an element. Do not raise an exception if absent.N(RQ(RR>((s/usr/lib64/python2.7/_abcoll.pytdiscardscCs,||krt|n|j|dS(s5Remove an element. If not a member, raise a KeyError.N(tKeyErrorRS(RR>((s/usr/lib64/python2.7/_abcoll.pytremoves cCsGt|}yt|}Wntk r5tnX|j||S(s2Return the popped value. Raise KeyError if empty.(titerR+R*RTRS(RR<R>((s/usr/lib64/python2.7/_abcoll.pytpop#s    cCs3yxtr|jqWWntk r.nXdS(s6This is slow (creates N new iterators!) but effective.N(RRWRT(R((s/usr/lib64/python2.7/_abcoll.pytclear-s   cCs"x|D]}|j|qW|S(N(RR(RR<R>((s/usr/lib64/python2.7/_abcoll.pyt__ior__5s cCs&x||D]}|j|q W|S(N(RS(RR<R>((s/usr/lib64/python2.7/_abcoll.pyt__iand__:scCsx||kr|jn[t|ts:|j|}nx7|D]/}||krc|j|qA|j|qAW|S(N(RXR2RR=RSRR(RR<R>((s/usr/lib64/python2.7/_abcoll.pyt__ixor__?s    cCs;||kr|jnx|D]}|j|q W|S(N(RXRS(RR<R>((s/usr/lib64/python2.7/_abcoll.pyt__isub__Ls    ( R$R%RPRRRRSRURWRXRYRZR[R\(((s/usr/lib64/python2.7/_abcoll.pyR s      cBseZdZedZd dZdZdZdZ dZ dZ dZ d Z d Zd Zd ZRS( sA Mapping is a generic container for associating key/value pairs. This class provides concrete generic implementations of all methods except for __getitem__, __iter__, and __len__. cCs tdS(N(RT(Rtkey((s/usr/lib64/python2.7/_abcoll.pyt __getitem__dscCs%y ||SWntk r |SXdS(s<D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None.N(RT(RR]tdefault((s/usr/lib64/python2.7/_abcoll.pytgeths  cCs)y ||Wntk r tSXtSdS(N(RTR(R(RR]((s/usr/lib64/python2.7/_abcoll.pyR.os   cCs t|S(s.D.iterkeys() -> an iterator over the keys of D(RV(R((s/usr/lib64/python2.7/_abcoll.pytiterkeyswsccsx|D]}||VqWdS(s2D.itervalues() -> an iterator over the values of DN((RR]((s/usr/lib64/python2.7/_abcoll.pyt itervalues{s ccs$x|D]}|||fVqWdS(s=D.iteritems() -> an iterator over the (key, value) items of DN((RR]((s/usr/lib64/python2.7/_abcoll.pyt iteritemss cCs t|S(sD.keys() -> list of D's keys(tlist(R((s/usr/lib64/python2.7/_abcoll.pytkeysscCs!g|D]}|||f^qS(s8D.items() -> list of D's (key, value) pairs, as 2-tuples((RR]((s/usr/lib64/python2.7/_abcoll.pytitemsscCsg|D]}||^qS(s D.values() -> list of D's values((RR]((s/usr/lib64/python2.7/_abcoll.pytvaluesscCs5t|tstSt|jt|jkS(N(R2R R!tdictRf(RR4((s/usr/lib64/python2.7/_abcoll.pyR:scCs ||k S(N((RR4((s/usr/lib64/python2.7/_abcoll.pyR;sN(R$R%RPRR^R R`R.RaRbRcReRfRgRR:R;(((s/usr/lib64/python2.7/_abcoll.pyR Zs         cBs#eZdZdZdZRS(cCs ||_dS(N(t_mapping(Rtmapping((s/usr/lib64/python2.7/_abcoll.pyt__init__scCs t|jS(N(R3Ri(R((s/usr/lib64/python2.7/_abcoll.pyR,scCs dj|S(Ns&{0.__class__.__name__}({0._mapping!r})(tformat(R((s/usr/lib64/python2.7/_abcoll.pyt__repr__s(R$R%RkR,Rm(((s/usr/lib64/python2.7/_abcoll.pyR s  cBs)eZedZdZdZRS(cCs t|S(N(tset(RR<((s/usr/lib64/python2.7/_abcoll.pyR=scCs ||jkS(N(Ri(RR]((s/usr/lib64/python2.7/_abcoll.pyR.sccsx|jD] }|Vq WdS(N(Ri(RR]((s/usr/lib64/python2.7/_abcoll.pyR)s(R$R%R'R=R.R)(((s/usr/lib64/python2.7/_abcoll.pyR s cBs)eZedZdZdZRS(cCs t|S(N(Rn(RR<((s/usr/lib64/python2.7/_abcoll.pyR=scCs@|\}}y|j|}Wntk r1tSX||kSdS(N(RiRTR((RtitemR]R>tv((s/usr/lib64/python2.7/_abcoll.pyR.s   ccs*x#|jD]}||j|fVq WdS(N(Ri(RR]((s/usr/lib64/python2.7/_abcoll.pyR)s(R$R%R'R=R.R)(((s/usr/lib64/python2.7/_abcoll.pyRs cBseZdZdZRS(cCs/x(|jD]}||j|kr tSq WtS(N(RiRR((RR>R]((s/usr/lib64/python2.7/_abcoll.pyR.sccs$x|jD]}|j|Vq WdS(N(Ri(RR]((s/usr/lib64/python2.7/_abcoll.pyR)s(R$R%R.R)(((s/usr/lib64/python2.7/_abcoll.pyRs cBsheZdZedZedZeZedZdZ dZ dZ ddZ RS( sA MutableMapping is a generic container for associating key/value pairs. This class provides concrete generic implementations of all methods except for __getitem__, __setitem__, __delitem__, __iter__, and __len__. cCs tdS(N(RT(RR]R>((s/usr/lib64/python2.7/_abcoll.pyt __setitem__scCs tdS(N(RT(RR]((s/usr/lib64/python2.7/_abcoll.pyt __delitem__scCsGy||}Wn'tk r7||jkr3n|SX||=|SdS(sD.pop(k[,d]) -> v, remove specified key and return the corresponding value. If key is not found, d is returned if given, otherwise KeyError is raised. N(RTt_MutableMapping__marker(RR]R_R>((s/usr/lib64/python2.7/_abcoll.pyRWs cCsKytt|}Wntk r/tnX||}||=||fS(sD.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty. (R+RVR*RT(RR]R>((s/usr/lib64/python2.7/_abcoll.pytpopitems   cCs3yxtr|jqWWntk r.nXdS(s,D.clear() -> None. Remove all items from D.N(RRtRT(R((s/usr/lib64/python2.7/_abcoll.pyRXs   cOs%t|dkr0tdjt|n|sEtdn|d}t|dkrk|dnd}t|trxw|D]}|||| None. Update D from mapping/iterable E and F. If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v is8update() takes at most 2 positional arguments ({} given)s,update() takes at least 1 argument (0 given)iiReN((R3t TypeErrorRlR2R RReRf(R/R0RR4R]R>((s/usr/lib64/python2.7/_abcoll.pytupdates"  " cCs.y ||SWntk r)||| D.get(k,d), also set D[k]=d if k not in D(RT(RR]R_((s/usr/lib64/python2.7/_abcoll.pyt setdefault(s   N(R$R%RPRRqRrtobjectRsRWRtRXRvR Rw(((s/usr/lib64/python2.7/_abcoll.pyR s     cBsJeZdZedZdZdZdZdZdZ RS(sAll the operations on a read-only sequence. Concrete subclasses must override __new__ or __init__, __getitem__, and __len__. cCs tdS(N(t IndexError(Rtindex((s/usr/lib64/python2.7/_abcoll.pyR^=sccsId}y*x#tr.||}|V|d7}q WWntk rDdSXdS(Nii(RRy(RtiRp((s/usr/lib64/python2.7/_abcoll.pyR)As   cCs%x|D]}||krtSqWtS(N(RR((RR>Rp((s/usr/lib64/python2.7/_abcoll.pyR.Ks  ccs0x)ttt|D]}||VqWdS(N(treversedtrangeR3(RR{((s/usr/lib64/python2.7/_abcoll.pyt __reversed__QscCs7x*t|D]\}}||kr |Sq WtdS(s|S.index(value) -> integer -- return first index of value. Raises ValueError if the value is not present. N(t enumeratet ValueError(RR>R{Rp((s/usr/lib64/python2.7/_abcoll.pyRzUs cstfd|DS(sBS.count(value) -> integer -- return number of occurrences of valuec3s!|]}|krdVqdS(iN((RRp(R>(s/usr/lib64/python2.7/_abcoll.pys `s(tsum(RR>((R>s/usr/lib64/python2.7/_abcoll.pytcount^s( R$R%RPRR^R)R.R~RzR(((s/usr/lib64/python2.7/_abcoll.pyR6s   cBsteZdZedZedZedZdZdZdZ ddZ d Z d Z RS( sAll the operations on a read-only sequence. Concrete subclasses must provide __new__ or __init__, __getitem__, __setitem__, __delitem__, __len__, and insert(). cCs tdS(N(Ry(RRzR>((s/usr/lib64/python2.7/_abcoll.pyRqqscCs tdS(N(Ry(RRz((s/usr/lib64/python2.7/_abcoll.pyRruscCs tdS(s5S.insert(index, object) -- insert object before indexN(Ry(RRzR>((s/usr/lib64/python2.7/_abcoll.pytinsertyscCs|jt||dS(s<S.append(object) -- append object to the end of the sequenceN(RR3(RR>((s/usr/lib64/python2.7/_abcoll.pytappend~scCsXt|}xEt|dD]3}|||d||||<|||d item -- remove and return item at index (default last). Raise IndexError if list is empty or index is out of range. ((RRzRp((s/usr/lib64/python2.7/_abcoll.pyRWs cCs||j|=dS(svS.remove(value) -- remove first occurrence of value. Raise ValueError if the value is not present. N(Rz(RR>((s/usr/lib64/python2.7/_abcoll.pyRUscCs|j||S(N(R(RRg((s/usr/lib64/python2.7/_abcoll.pyt__iadd__s ( R$R%RPRRqRrRRRRRWRUR(((s/usr/lib64/python2.7/_abcoll.pyRhs     ((((((!RPtabcRRRGt__all__RRRtregistertstrRRRRRt frozensetR RnR R R RRR RhRttuplet basestringtbuffertxrangeRRd(((s/usr/lib64/python2.7/_abcoll.pyt sD       y M B  Y ,    7