3 \g@srdZddlmZmZddlZdddddd d d d d dddddddddddddddgZdZeedZ eee Z eeij Z eeijZeeijZeegZeeegZeeedZeeedd >ZeeeZeed!ZeefZeeeZeij ZeijZeijZ eej!Z"ed"d#Z#d$d%Z$e$Z$ee$Z%e$j&[$d&d'Z'e'Z'ee'Z(['d(d)Z)Gd*d d ed+Z*Gd,dded+Z+Gd-dde+Z,e,j-e%Gd.dded+Z.Gd/dde.Z/Gd0dde/Z0e0j-e(Gd1d d ed+Z1Gd2d d e1Z2e2j-e e2j-e e2j-e e2j-ee2j-ee2j-ee2j-ee2j-ee2j-ee2j-ee2j-ee2j-ee2j-eGd3d d e1Z3Gd4d d e2Z4e4j-e#Gd5dded+Z5Gd6dded+Z6Gd7dde5e1e6Z7Gd8dded+Z8Gd9dde7Z9e9j-e:Gd:dde9Z;e;j-eGd;dde7Ze>j-eGd>dde=e9Z?e?j-e Gd?dde=Z@e@j-eGd@dde<ZAeAj-eBGdAdde3e7ZCeCj-eDeCj-eEeCj-eeCj-eFGdBddeCZGeGj-eHeGj-e GdCddeCZIeIj-eJeIj-e dS)DzjAbstract Base Classes (ABCs) for collections, according to PEP 3119. Unit tests are in test_collections. )ABCMetaabstractmethodN Awaitable Coroutine AsyncIterable AsyncIteratorAsyncGeneratorHashableIterableIterator Generator ReversibleSized ContainerCallable CollectionSet MutableSetMappingMutableMapping MappingViewKeysView ItemsView ValuesViewSequenceMutableSequence ByteStringzcollections.abciccsdVS)Nr r r (/usr/lib64/python3.6/_collections_abc.py8sr"csdS)Nr r r r r!_coro:sr#cCs dVdS)Nr r r r r!_ag@sr$cGsH|j}x<|D]4}x.|D]"}||jkr|j|dkr6tSPqWtSq WdS)NT)__mro____dict__NotImplemented)CmethodsmromethodBr r r!_check_methodsHs   r-c@s(eZdZfZeddZeddZdS)r cCsdS)Nrr )selfr r r!__hash__XszHashable.__hash__cCs|tkrt|dStS)Nr/)r r-r')clsr(r r r!__subclasshook__\s zHashable.__subclasshook__N)__name__ __module__ __qualname__ __slots__rr/ classmethodr1r r r r!r Ts ) metaclassc@s(eZdZfZeddZeddZdS)rccs dVdS)Nr )r.r r r! __await__gszAwaitable.__await__cCs|tkrt|dStS)Nr8)rr-r')r0r(r r r!r1ks zAwaitable.__subclasshook__N)r2r3r4r5rr8r6r1r r r r!rcs c@s>eZdZfZeddZed ddZddZedd Z dS) rcCstdS)zcSend a value into the coroutine. Return next yielded value or raise StopIteration. N) StopIteration)r.valuer r r!sendvszCoroutine.sendNcCs4|dkr|dkr||}|dk r,|j|}|dS)zgRaise an exception in the coroutine. Return next yielded value or raise StopIteration. N)with_traceback)r.typvaltbr r r!throw}s zCoroutine.throwc Cs4y|jtWnttfk r&Yn XtddS)z.Raise GeneratorExit inside coroutine. zcoroutine ignored GeneratorExitN)r@ GeneratorExitr9 RuntimeError)r.r r r!closes zCoroutine.closecCs|tkrt|ddddStS)Nr8r;r@rC)rr-r')r0r(r r r!r1szCoroutine.__subclasshook__)NN) r2r3r4r5rr;r@rCr6r1r r r r!rrs    c@s(eZdZfZeddZeddZdS)rcCstS)N)r)r.r r r! __aiter__szAsyncIterable.__aiter__cCs|tkrt|dStS)NrD)rr-r')r0r(r r r!r1s zAsyncIterable.__subclasshook__N)r2r3r4r5rrDr6r1r r r r!rs c@s0eZdZfZeddZddZeddZdS)rcstdS)z@Return the next item or raise StopAsyncIteration when exhausted.N)StopAsyncIteration)r.r r r! __anext__szAsyncIterator.__anext__cCs|S)Nr )r.r r r!rDszAsyncIterator.__aiter__cCs|tkrt|ddStS)NrFrD)rr-r')r0r(r r r!r1s zAsyncIterator.__subclasshook__N) r2r3r4r5rrFrDr6r1r r r r!rs c@sFeZdZfZddZeddZed ddZdd Ze d d Z dS) rcs|jdIdHS)zpReturn the next item from the asynchronous generator. When exhausted, raise StopAsyncIteration. N)asend)r.r r r!rFszAsyncGenerator.__anext__cstdS)zuSend a value into the asynchronous generator. Return next yielded value or raise StopAsyncIteration. N)rE)r.r:r r r!rGszAsyncGenerator.asendNcs4|dkr|dkr||}|dk r,|j|}|dS)zyRaise an exception in the asynchronous generator. Return next yielded value or raise StopAsyncIteration. N)r<)r.r=r>r?r r r!athrows zAsyncGenerator.athrowc s:y|jtIdHWnttfk r,Yn XtddS)z.Raise GeneratorExit inside coroutine. Nz,asynchronous generator ignored GeneratorExit)rHrArErB)r.r r r!acloses zAsyncGenerator.aclosecCs|tkrt|dddddStS)NrDrFrGrHrI)rr-r')r0r(r r r!r1s zAsyncGenerator.__subclasshook__)NN) r2r3r4r5rFrrGrHrIr6r1r r r r!rs   c@s(eZdZfZeddZeddZdS)r ccsdS)Nr )r.r r r!__iter__szIterable.__iter__cCs|tkrt|dStS)NrJ)r r-r')r0r(r r r!r1s zIterable.__subclasshook__N)r2r3r4r5rrJr6r1r r r r!r s c@s0eZdZfZeddZddZeddZdS)r cCstdS)zKReturn the next item from the iterator. When exhausted, raise StopIterationN)r9)r.r r r!__next__szIterator.__next__cCs|S)Nr )r.r r r!rJ szIterator.__iter__cCs|tkrt|ddStS)NrJrK)r r-r')r0r(r r r!r1s zIterator.__subclasshook__N) r2r3r4r5rrKrJr6r1r r r r!r s c@s(eZdZfZeddZeddZdS)r ccsdS)Nr )r.r r r! __reversed__)szReversible.__reversed__cCs|tkrt|ddStS)NrLrJ)r r-r')r0r(r r r!r1.s zReversible.__subclasshook__N)r2r3r4r5rrLr6r1r r r r!r %s c@sFeZdZfZddZeddZed ddZdd Ze d d Z dS) r cCs |jdS)z^Return the next item from the generator. When exhausted, raise StopIteration. N)r;)r.r r r!rK9szGenerator.__next__cCstdS)zcSend a value into the generator. Return next yielded value or raise StopIteration. N)r9)r.r:r r r!r;?szGenerator.sendNcCs4|dkr|dkr||}|dk r,|j|}|dS)zgRaise an exception in the generator. Return next yielded value or raise StopIteration. N)r<)r.r=r>r?r r r!r@Fs zGenerator.throwc Cs4y|jtWnttfk r&Yn XtddS)z.Raise GeneratorExit inside generator. zgenerator ignored GeneratorExitN)r@rAr9rB)r.r r r!rCSs zGenerator.closecCs|tkrt|dddddStS)NrJrKr;r@rC)r r-r')r0r(r r r!r1]s zGenerator.__subclasshook__)NN) r2r3r4r5rKrr;r@rCr6r1r r r r!r 5s   c@s(eZdZfZeddZeddZdS)rcCsdS)Nrr )r.r r r!__len__ksz Sized.__len__cCs|tkrt|dStS)NrM)rr-r')r0r(r r r!r1os zSized.__subclasshook__N)r2r3r4r5rrMr6r1r r r r!rgs c@s(eZdZfZeddZeddZdS)rcCsdS)NFr )r.xr r r! __contains__zszContainer.__contains__cCs|tkrt|dStS)NrO)rr-r')r0r(r r r!r1~s zContainer.__subclasshook__N)r2r3r4r5rrOr6r1r r r r!rvs c@seZdZfZeddZdS)rcCs|tkrt|dddStS)NrMrJrO)rr-r')r0r(r r r!r1szCollection.__subclasshook__N)r2r3r4r5r6r1r r r r!rsc@s(eZdZfZeddZeddZdS)rcOsdS)NFr )r.argskwdsr r r!__call__szCallable.__call__cCs|tkrt|dStS)NrR)rr-r')r0r(r r r!r1s zCallable.__subclasshook__N)r2r3r4r5rrRr6r1r r r r!rs c@seZdZdZfZddZddZddZdd Zd d Z e d d Z ddZ e Z ddZddZeZddZddZddZeZddZdS)raZA 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), redefine __le__ and __ge__, then the other operations will automatically follow suit. cCs@t|tstSt|t|kr"dSx|D]}||kr(dSq(WdS)NFT) isinstancerr'len)r.otherelemr r r!__le__s  z Set.__le__cCs(t|tstSt|t|ko&|j|S)N)rSrr'rTrW)r.rUr r r!__lt__s z Set.__lt__cCs(t|tstSt|t|ko&|j|S)N)rSrr'rT__ge__)r.rUr r r!__gt__s z Set.__gt__cCs@t|tstSt|t|kr"dSx|D]}||kr(dSq(WdS)NFT)rSrr'rT)r.rUrVr r r!rYs  z Set.__ge__cCs(t|tstSt|t|ko&|j|S)N)rSrr'rTrW)r.rUr r r!__eq__s z Set.__eq__cCs||S)zConstruct 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 )r0itr r r!_from_iterableszSet._from_iterablecs&t|tstSjfdd|DS)Nc3s|]}|kr|VqdS)Nr ).0r:)r.r r! szSet.__and__..)rSr r'r])r.rUr )r.r!__and__s z Set.__and__cCsx|D]}||krdSqWdS)z1Return True if two sets have a null intersection.FTr )r.rUr:r r r! isdisjoints zSet.isdisjointcCs*t|tstSdd||fD}|j|S)Ncss|]}|D] }|Vq qdS)Nr )r^ser r r!r_szSet.__or__..)rSr r'r])r.rUchainr r r!__or__s z Set.__or__cs:tts"ttstS|j|jfdd|DS)Nc3s|]}|kr|VqdS)Nr )r^r:)rUr r!r_szSet.__sub__..)rSrr r'r])r.rUr )rUr!__sub__s    z Set.__sub__cs:t|ts"t|tstSj|}jfdd|DS)Nc3s|]}|kr|VqdS)Nr )r^r:)r.r r!r_szSet.__rsub__..)rSrr r'r])r.rUr )r.r!__rsub__s    z Set.__rsub__cCs2t|ts"t|tstS|j|}||||BS)N)rSrr r'r])r.rUr r r!__xor__s    z Set.__xor__cCstj}d|d}t|}d|d}||M}x4|D],}t|}|||d>AdAdN}||M}q4W|dd}||M}||kr||d8}|d krd }|S) a+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. riMriM[l4~2i i6i8#)sysmaxsizerThash)r.MAXMASKnhrNhxr r r!_hash s       z Set._hashN)r2r3r4__doc__r5rWrXrZrYr[r6r]r`__rand__rare__ror__rfrgrh__rxor__rtr r r r!rs$    c@sdeZdZdZfZeddZeddZddZdd Z d d Z d d Z ddZ ddZ ddZdS)raA 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. cCstdS)zAdd an element.N)NotImplementedError)r.r:r r r!add:szMutableSet.addcCstdS)z8Remove an element. Do not raise an exception if absent.N)ry)r.r:r r r!discard?szMutableSet.discardcCs||krt||j|dS)z5Remove an element. If not a member, raise a KeyError.N)KeyErrorr{)r.r:r r r!removeDszMutableSet.removec Cs<t|}y t|}Wntk r,tYnX|j||S)z2Return the popped value. Raise KeyError if empty.)iternextr9r|r{)r.r\r:r r r!popJs   zMutableSet.popc Cs,yx |jqWWntk r&YnXdS)z6This is slow (creates N new iterators!) but effective.N)rr|)r.r r r!clearTs zMutableSet.clearcCsx|D]}|j|qW|S)N)rz)r.r\r:r r r!__ior__\s zMutableSet.__ior__cCs x||D]}|j|q W|S)N)r{)r.r\r:r r r!__iand__aszMutableSet.__iand__cCsV||kr|jn@t|ts&|j|}x*|D]"}||krD|j|q,|j|q,W|S)N)rrSrr]r{rz)r.r\r:r r r!__ixor__fs     zMutableSet.__ixor__cCs.||kr|jnx|D]}|j|qW|S)N)rr{)r.r\r:r r r!__isub__ss   zMutableSet.__isub__N)r2r3r4rur5rrzr{r}rrrrrrr r r r!r,s     c@sReZdZfZeddZdddZddZdd Zd d Z d d Z ddZ dZ dS)rcCstdS)N)r|)r.keyr r r! __getitem__szMapping.__getitem__Nc Cs"y||Stk r|SXdS)z D[k] if k in D, else d. d defaults to None.N)r|)r.rdefaultr r r!getsz Mapping.getc Cs*y ||Wntk r dSXdSdS)NFT)r|)r.rr r r!rOs  zMapping.__contains__cCst|S)z:D.keys() -> a set-like object providing a view on D's keys)r)r.r r r!keyssz Mapping.keyscCst|S)z a set-like object providing a view on D's items)r)r.r r r!itemssz Mapping.itemscCst|S)z6D.values() -> an object providing a view on D's values)r)r.r r r!valuesszMapping.valuescCs&t|tstSt|jt|jkS)N)rSrr'dictr)r.rUr r r!r[s zMapping.__eq__)N) r2r3r4r5rrrrOrrrr[rLr r r r!rs  c@s(eZdZd ZddZddZddZdS) r_mappingcCs ||_dS)N)r)r.mappingr r r!__init__szMappingView.__init__cCs t|jS)N)rTr)r.r r r!rMszMappingView.__len__cCs dj|S)Nz&{0.__class__.__name__}({0._mapping!r}))format)r.r r r!__repr__szMappingView.__repr__N)r)r2r3r4r5rrMrr r r r!rsc@s,eZdZfZeddZddZddZdS)rcCst|S)N)set)r.r\r r r!r]szKeysView._from_iterablecCs ||jkS)N)r)r.rr r r!rOszKeysView.__contains__ccs|jEdHdS)N)r)r.r r r!rJszKeysView.__iter__N)r2r3r4r5r6r]rOrJr r r r!rs c@s,eZdZfZeddZddZddZdS)rcCst|S)N)r)r.r\r r r!r]szItemsView._from_iterablec Cs@|\}}y|j|}Wntk r*dSX||kp:||kSdS)NF)rr|)r.itemrr:vr r r!rOs zItemsView.__contains__ccs$x|jD]}||j|fVqWdS)N)r)r.rr r r!rJs zItemsView.__iter__N)r2r3r4r5r6r]rOrJr r r r!rs  c@s eZdZfZddZddZdS)rcCs2x,|jD]"}|j|}||ks&||krdSqWdS)NTF)r)r.r:rrr r r!rOs   zValuesView.__contains__ccs x|jD]}|j|VqWdS)N)r)r.rr r r!rJs zValuesView.__iter__N)r2r3r4r5rOrJr r r r!rsc@s\eZdZfZeddZeddZeZefddZ ddZ d d Z d d Z dddZ d S)rcCstdS)N)r|)r.rr:r r r! __setitem__ szMutableMapping.__setitem__cCstdS)N)r|)r.rr r r! __delitem__szMutableMapping.__delitem__c Cs<y ||}Wn tk r,||jkr(|SX||=|SdS)zD.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)r|_MutableMapping__marker)r.rrr:r r r!rs  zMutableMapping.popc Cs@ytt|}Wntk r(tYnX||}||=||fS)zD.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty. )rr~r9r|)r.rr:r r r!popitem$s zMutableMapping.popitemc Cs,yx |jqWWntk r&YnXdS)z,D.clear() -> None. Remove all items from D.N)rr|)r.r r r!r0s zMutableMapping.clearcOs|s td|^}}t|dkr0tdt||r|d}t|trbx^|D]}||||<qLWnDt|drx8|jD]}||||<qvWnx|D]\}}|||<qWx|jD]\}}|||<qWdS)aK D.update([E, ]**F) -> 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 z@descriptor 'update' of 'MutableMapping' object needs an argumentrz+update expected at most 1 arguments, got %drrN) TypeErrorrTrSrhasattrrr)rPrQr.rUrr:r r r!update8s$      zMutableMapping.updateNc Cs*y||Stk r$|||<YnX|S)z@D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D)r|)r.rrr r r! setdefaultSs zMutableMapping.setdefault)N)r2r3r4r5rrrobjectrrrrrrr r r r!rs    c@sJeZdZdZfZeddZddZddZdd Z dd d Z ddZ d S)rzAll the operations on a read-only sequence. Concrete subclasses must override __new__ or __init__, __getitem__, and __len__. cCstdS)N) IndexError)r.indexr r r!rkszSequence.__getitem__c cs>d}y x||}|V|d7}qWWntk r8dSXdS)Nrr)r)r.irr r r!rJoszSequence.__iter__cCs&x |D]}||ks||krdSqWdS)NTFr )r.r:rr r r!rOys zSequence.__contains__ccs(x"ttt|D]}||VqWdS)N)reversedrangerT)r.rr r r!rLszSequence.__reversed__rNc Cs|dk r"|dkr"tt||d}|dk r>|dkr>|t|7}|}xT|dksT||kry ||}||ksn||krr|SWntk rPYnX|d7}qDWtdS)zS.index(value, [start, [stop]]) -> integer -- return first index of value. Raises ValueError if the value is not present. Supporting start and stop arguments is optional, but recommended. Nrr)maxrTr ValueError)r.r:startstoprrr r r!rs  zSequence.indexcstfdd|DS)zBS.count(value) -> integer -- return number of occurrences of valuec3s"|]}|ks|krdVqdS)rNr )r^r)r:r r!r_sz!Sequence.count..)sum)r.r:r )r:r!countszSequence.count)rN) r2r3r4rur5rrrJrOrLrrr r r r!ras   c@seZdZdZfZdS)rzMThis unifies bytes and bytearray. XXX Should add all their methods. N)r2r3r4rur5r r r r!rsc@sneZdZfZeddZeddZeddZddZd d Z d d Z d dZ dddZ ddZ ddZdS)rcCstdS)N)r)r.rr:r r r!rszMutableSequence.__setitem__cCstdS)N)r)r.rr r r!rszMutableSequence.__delitem__cCstdS)z3S.insert(index, value) -- insert value before indexN)r)r.rr:r r r!insertszMutableSequence.insertcCs|jt||dS)z:S.append(value) -- append value to the end of the sequenceN)rrT)r.r:r r r!appendszMutableSequence.appendc Cs,yx |jqWWntk r&YnXdS)z,S.clear() -> None -- remove all items from SN)rr)r.r r r!rs zMutableSequence.clearcCsLt|}x>t|dD].}|||d||||<|||d<qWdS)z!S.reverse() -- reverse *IN PLACE*rirN)rTr)r.rqrr r r!reverseszMutableSequence.reversecCsx|D]}|j|qWdS)zMS.extend(iterable) -- extend sequence by appending elements from the iterableN)r)r.rrr r r!extends zMutableSequence.extendrcCs||}||=|S)zS.pop([index]) -> item -- remove and return item at index (default last). Raise IndexError if list is empty or index is out of range. r )r.rrr r r!rszMutableSequence.popcCs||j|=dS)zvS.remove(value) -- remove first occurrence of value. Raise ValueError if the value is not present. N)r)r.r:r r r!r}szMutableSequence.removecCs|j||S)N)r)r.rr r r!__iadd__s zMutableSequence.__iadd__Nrk)rk)r2r3r4r5rrrrrrrrrr}rr r r r!rs    )Kruabcrrrl__all__r2typer~bytes_iterator bytearraybytearray_iteratorrdict_keyiteratorrdict_valueiteratorrdict_itemiterator list_iteratorrlist_reverseiteratorrrange_iteratorlongrange_iteratorr set_iterator str_iteratortuple_iteratorzip zip_iterator dict_keys dict_values dict_itemsr& mappingproxy generatorr# coroutinerCr$async_generatorr-r rrregisterrrrr r r r rrrrr frozensetrrrrrrrrrtuplestr memoryviewrbytesrlistr r r r!s          ) 0              /   O 2    \ =      A