B J^@stdZddlmZmZddlZdddddd d d d d dddddddddddddddgZdZeedZ eee Z eei Z eeiZeeiZeegZeeegZeeedZeeedd >ZeeeZeed!Zeed"ZeeeZei ZeiZeiZ eej!Z"ed#d$Z#d%d&Z$e$Z$ee$Z%e$&[$d'd(Z'e'Z'ee'Z(['d)d*Z)Gd+d d ed,Z*Gd-dded,Z+Gd.dde+Z,e,-e%Gd/dded,Z.Gd0dde.Z/Gd1dde/Z0e0-e(Gd2d d ed,Z1Gd3d d e1Z2e2-e e2-e e2-e e2-ee2-ee2-ee2-ee2-ee2-ee2-ee2-ee2-ee2-eGd4d d e1Z3Gd5d d e2Z4e4-e#Gd6dded,Z5Gd7dded,Z6Gd8dde5e1e6Z7Gd9dded,Z8Gd:dde7Z9e9-e:Gd;dde9Z;e;-eGddde=e9Z>e>-eGd?dde=e9Z?e?-e Gd@dde=e7Z@e@-eGdAdde<ZAeA-eBGdBdde3e7ZCeC-eDeC-eEeC-eeC-eFGdCddeCZGeG-eHeG-e GdDddeCZIeI-eJeI-e dS)EzjAbstract 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 r 3/opt/alt/python37/lib/python3.7/_collections_abc.py8rr"csdS)Nr r r r r!_coro:rr#cCs dVdS)Nr r r r r!_ag@rr$cGsH|j}x<|D]4}x.|D]"}||jkr|j|dkr6tSPqWtSq WdS)NT)__mro____dict__NotImplemented)CmethodsmromethodBr r r!_check_methodsHs   r-c@s(eZdZdZeddZeddZdS)r 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(eZdZdZeddZeddZdS)rr ccs 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>eZdZdZeddZed ddZddZed d Z dS) rr cCstdS)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,||}|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|tWnttfk 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(eZdZdZeddZeddZdS)rr cCstS)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@s0eZdZdZeddZddZeddZdS) rr cstdS)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@sFeZdZdZddZeddZed ddZd d Ze d d Z dS)rr cs|dIdHS)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,||}|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|tIdHWnttfk 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(eZdZdZeddZeddZdS)r 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@s0eZdZdZeddZddZeddZdS) r 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(eZdZdZeddZeddZdS)r 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@sFeZdZdZddZeddZed ddZd d Ze d d Z dS)r r cCs |dS)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,||}|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|tWnttfk 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(eZdZdZeddZeddZdS)rr cCsdS)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(eZdZdZeddZeddZdS)rr cCsdS)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@seZdZdZeddZdS)rr cCs|tkrt|dddStS)NrMrJrO)rr-r')r0r(r r r!r1szCollection.__subclasshook__N)r2r3r4r5r6r1r r r r!rsc@s(eZdZdZeddZeddZdS)rr cOsdS)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@seZdZdZdZddZddZddZd d Zd d Z e d dZ 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. r 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&||S)N)rSrr'rTrW)r.rUr r r!__lt__s z Set.__lt__cCs(t|tstSt|t|ko&||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&||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|tstSfdd|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}||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||fdd|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|tstS|}fdd|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||}||||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@sdeZdZdZdZeddZeddZddZd d Z d d Z d dZ 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. r 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|||dS)z5Remove an element. If not a member, raise a KeyError.N)KeyErrorr{)r.r:r r r!removeDszMutableSet.removecCs>t|}y t|}Wntk r.tdYnX|||S)z2Return the popped value. Raise KeyError if empty.N)iternextr9r|r{)r.r\r:r r r!popJs   zMutableSet.popcCs,yx |qWWntk r&YnXdS)z6This is slow (creates N new iterators!) but effective.N)rr|)r.r r r!clearTs zMutableSet.clearcCsx|D]}||qW|S)N)rz)r.r\r:r r r!__ior__\s zMutableSet.__ior__cCs x||D]}||q W|S)N)r{)r.r\r:r r r!__iand__aszMutableSet.__iand__cCsV||kr|n@t|ts&||}x*|D]"}||krD||q,||q,W|S)N)rrSrr]r{rz)r.r\r:r r r!__ixor__fs     zMutableSet.__ixor__cCs.||kr|nx|D]}||qW|S)N)rr{)r.r\r:r r r!__isub__ss   zMutableSet.__isub__N)r2r3r4rur5rrzr{r}rrrrrrr r r r!r,s     c@sReZdZdZeddZdddZddZd d Zd d Z d dZ ddZ dZ dS)rr cCstdS)N)r|)r.keyr r r! __getitem__szMapping.__getitem__NcCs"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.getcCs*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|t|kS)N)rSrr'dictr)r.rUr r r!r[s zMapping.__eq__)N) r2r3r4r5rrrrOrrrr[rLr r r r!rs  c@s(eZdZdZddZddZddZdS) r)_mappingcCs ||_dS)N)r)r.mappingr r r!__init__szMappingView.__init__cCs t|jS)N)rTr)r.r r r!rMszMappingView.__len__cCs d|S)Nz&{0.__class__.__name__}({0._mapping!r}))format)r.r r r!__repr__szMappingView.__repr__N)r2r3r4r5rrMrr r r r!rsc@s,eZdZdZeddZddZddZdS) rr cCst|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,eZdZdZeddZddZddZdS) rr cCst|S)N)r)r.r\r r r!r]szItemsView._from_iterablecCs@|\}}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 eZdZdZddZddZdS)rr cCs2x,|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\eZdZdZeddZeddZeZefddZ dd Z d d Z d d Z dddZ dS)rr cCstdS)N)r|)r.rr:r r r! __setitem__ szMutableMapping.__setitem__cCstdS)N)r|)r.rr r r! __delitem__szMutableMapping.__delitem__cCs<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.popcCsBytt|}Wntk r*tdYnX||}||=||fS)zD.popitem() -> (k, v), remove and return some (key, value) pair as a 2-tuple; but raise KeyError if D is empty. N)rr~r9r|)r.rr:r r r!popitem$s zMutableMapping.popitemcCs,yx |qWWntk 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|D]}||||<qvWnx|D]\}}|||<qWx|D]\}}|||<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.updateNcCs*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@sJeZdZdZdZeddZddZddZd d Z dd dZ ddZ d S)rzAll the operations on a read-only sequence. Concrete subclasses must override __new__ or __init__, __getitem__, and __len__. r cCstdS)N) IndexError)r.indexr r r!rkszSequence.__getitem__ccs>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__rNcCs|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@seZdZdZdZdS)rzMThis unifies bytes and bytearray. XXX Should add all their methods. r N)r2r3r4rur5r r r r!rsc@sneZdZdZeddZeddZeddZdd Zd d Z d d Z ddZ dddZ ddZ ddZdS)rr cCstdS)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|t||dS)z:S.append(value) -- append value to the end of the sequenceN)rrT)r.r:r r r!appendszMutableSequence.appendcCs,yx |qWWntk 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]}||qWdS)zMS.extend(iterable) -- extend sequence by appending elements from the iterableN)r)r.rrr r r!extends zMutableSequence.extendrkcCs||}||=|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|||=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|||S)N)r)r.rr r r!__iadd__s zMutableSequence.__iadd__N)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