U e5de@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.abciccsdVSNr r r r (/usr/lib64/python3.8/_collections_abc.py8rr#csdSr!r r r r r"_coro:rr$cCs dVdSr!r r r r r"_ag@rr%cGsN|j}|D]>}|D],}||jkr|j|dkr:tSq qtSq dS)NT)__mro____dict__NotImplemented)CmethodsmromethodBr r r"_check_methodsHs   r.c@s(eZdZdZeddZeddZdS)r r cCsdSNrr selfr r r"__hash__XszHashable.__hash__cCs|tkrt|dStS)Nr2)r r.r(clsr)r r r"__subclasshook__\s zHashable.__subclasshook__N)__name__ __module__ __qualname__ __slots__rr2 classmethodr5r r r r"r Ts  ) metaclassc@s(eZdZdZeddZeddZdS)rr ccs dVdSr!r r0r r r" __await__gszAwaitable.__await__cCs|tkrt|dStS)Nr<)rr.r(r3r r r"r5ks zAwaitable.__subclasshook__N)r6r7r8r9rr<r:r5r 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 StopIterationr1valuer r r"sendvszCoroutine.sendNcCs4|dkr|dkr||}|dk r,||}|dS)zgRaise an exception in the coroutine. Return next yielded value or raise StopIteration. Nwith_tracebackr1typvaltbr r r"throw}s zCoroutine.throwc Cs4z|tWnttfk r&Yn XtddS).Raise GeneratorExit inside coroutine. zcoroutine ignored GeneratorExitNrH GeneratorExitr> RuntimeErrorr0r r r"closes zCoroutine.closecCs|tkrt|ddddStS)Nr<rArHrM)rr.r(r3r r r"r5szCoroutine.__subclasshook__)NN) r6r7r8r9rrArHrMr:r5r r r r"rrs   c@s(eZdZdZeddZeddZdS)rr cCstSr!)rr0r r r" __aiter__szAsyncIterable.__aiter__cCs|tkrt|dStS)NrN)rr.r(r3r r r"r5s zAsyncIterable.__subclasshook__N)r6r7r8r9rrNr:r5r r r r"rs  c@s0eZdZdZeddZddZeddZdS) rr cstdS)z@Return the next item or raise StopAsyncIteration when exhausted.NStopAsyncIterationr0r r r" __anext__szAsyncIterator.__anext__cCs|Sr!r r0r r r"rNszAsyncIterator.__aiter__cCs|tkrt|ddStS)NrQrN)rr.r(r3r r r"r5s zAsyncIterator.__subclasshook__N) r6r7r8r9rrQrNr:r5r 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)asendr0r r r"rQszAsyncGenerator.__anext__cstdS)zuSend a value into the asynchronous generator. Return next yielded value or raise StopAsyncIteration. NrOr?r r r"rRszAsyncGenerator.asendNcs4|dkr|dkr||}|dk r,||}|dS)zyRaise an exception in the asynchronous generator. Return next yielded value or raise StopAsyncIteration. NrBrDr r r"athrows zAsyncGenerator.athrowc s:z|tIdHWnttfk r,Yn XtddS)rINz,asynchronous generator ignored GeneratorExit)rSrKrPrLr0r r r"acloses zAsyncGenerator.aclosecCs|tkrt|dddddStS)NrNrQrRrSrT)rr.r(r3r r r"r5szAsyncGenerator.__subclasshook__)NN) r6r7r8r9rQrrRrSrTr:r5r r r r"rs   c@s(eZdZdZeddZeddZdS)r r ccsdSr!r r0r r r"__iter__szIterable.__iter__cCs|tkrt|dStS)NrU)r r.r(r3r r r"r5s zIterable.__subclasshook__N)r6r7r8r9rrUr:r5r r r r"r s  c@s0eZdZdZeddZddZeddZdS) r r cCstdS)zKReturn the next item from the iterator. When exhausted, raise StopIterationNr=r0r r r"__next__szIterator.__next__cCs|Sr!r r0r r r"rU szIterator.__iter__cCs|tkrt|ddStS)NrUrV)r r.r(r3r r r"r5s zIterator.__subclasshook__N) r6r7r8r9rrVrUr:r5r r r r"r s  c@s(eZdZdZeddZeddZdS)r r ccsdSr!r r0r r r" __reversed__)szReversible.__reversed__cCs|tkrt|ddStS)NrWrU)r r.r(r3r r r"r5.s zReversible.__subclasshook__N)r6r7r8r9rrWr:r5r 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)rAr0r r r"rV9szGenerator.__next__cCstdS)zcSend a value into the generator. Return next yielded value or raise StopIteration. Nr=r?r r r"rA?szGenerator.sendNcCs4|dkr|dkr||}|dk r,||}|dS)zgRaise an exception in the generator. Return next yielded value or raise StopIteration. NrBrDr r r"rHFs zGenerator.throwc Cs4z|tWnttfk r&Yn XtddS)z.Raise GeneratorExit inside generator. zgenerator ignored GeneratorExitNrJr0r r r"rMSs zGenerator.closecCs|tkrt|dddddStS)NrUrVrArHrM)r r.r(r3r r r"r5]szGenerator.__subclasshook__)NN) r6r7r8r9rVrrArHrMr:r5r r r r"r 5s   c@s(eZdZdZeddZeddZdS)rr cCsdSr/r r0r r r"__len__ksz Sized.__len__cCs|tkrt|dStS)NrX)rr.r(r3r r r"r5os zSized.__subclasshook__N)r6r7r8r9rrXr:r5r r r r"rgs  c@s(eZdZdZeddZeddZdS)rr cCsdSNFr )r1xr r r" __contains__zszContainer.__contains__cCs|tkrt|dStS)Nr[)rr.r(r3r r r"r5~s zContainer.__subclasshook__N)r6r7r8r9rr[r:r5r r r r"rvs  c@seZdZdZeddZdS)rr cCs|tkrt|dddStS)NrXrUr[)rr.r(r3r r r"r5szCollection.__subclasshook__N)r6r7r8r9r:r5r r r r"rsc@s(eZdZdZeddZeddZdS)rr cOsdSrYr )r1argskwdsr r r"__call__szCallable.__call__cCs|tkrt|dStS)Nr^)rr.r(r3r r r"r5s zCallable.__subclasshook__N)r6r7r8r9rr^r:r5r 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"dS|D]}||kr&dSq&dSNFT isinstancerr(lenr1otherelemr r r"__le__s z Set.__le__cCs(t|tstSt|t|ko&||Sr!rarr(rbrfr1rdr r r"__lt__s z Set.__lt__cCs(t|tstSt|t|ko&||Sr!)rarr(rb__ge__rhr r r"__gt__s z Set.__gt__cCs>t|tstSt|t|kr"dS|D]}||kr&dSq&dSr_r`rcr r r"rjs z Set.__ge__cCs(t|tstSt|t|ko&||Sr!rgrhr 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 )r4itr r r"_from_iterableszSet._from_iterablecs&t|tstSfdd|DS)Nc3s|]}|kr|VqdSr!r .0r@r0r r" szSet.__and__..rar r(rnrhr r0r"__and__s z Set.__and__cCs|D]}||krdSqdS)z1Return True if two sets have a null intersection.FTr )r1rdr@r r r" isdisjointszSet.isdisjointcCs*t|tstSdd||fD}||S)Ncss|]}|D] }|Vq qdSr!r )rpser r r"rqszSet.__or__..rr)r1rdchainr r r"__or__s z Set.__or__cs:tts"ttstS||fdd|DS)Nc3s|]}|kr|VqdSr!r rordr r"rqszSet.__sub__..rarr r(rnrhr ryr"__sub__s    z Set.__sub__cs:t|ts"t|tstS|}fdd|DS)Nc3s|]}|kr|VqdSr!r ror0r r"rqszSet.__rsub__..rzrhr r0r"__rsub__s    z Set.__rsub__cCs2t|ts"t|tstS||}||||BSr!rzrhr r r"__xor__s    z Set.__xor__cCstj}d|d}t|}d|d}||M}|D],}t|}|||d>AdAdN}||M}q2|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#)sysmaxsizerbhash)r1MAXMASKnhrZhxr r r"_hash s      z Set._hashN)r6r7r8__doc__r9rfrirkrjrlr:rnrs__rand__rtrx__ror__r{r|r}__rxor__rr 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.NNotImplementedErrorr?r r r"add:szMutableSet.addcCstdS)z8Remove an element. Do not raise an exception if absent.Nrr?r r r"discard?szMutableSet.discardcCs||krt|||dS)z5Remove an element. If not a member, raise a KeyError.N)KeyErrorrr?r r r"removeDszMutableSet.removecCs>t|}z t|}Wntk r.tdYnX|||S)z2Return the popped value. Raise KeyError if empty.N)iternextr>rrr1rmr@r r r"popJs   zMutableSet.popcCs(z|qWntk r"YnXdS)z6This is slow (creates N new iterators!) but effective.N)rrr0r r r"clearTszMutableSet.clearcCs|D]}||q|Sr!)rrr r r"__ior__\s zMutableSet.__ior__cCs||D]}||q|Sr!)rrr r r"__iand__as  zMutableSet.__iand__cCsR||kr|n D[k] if k in D, else d. d defaults to None.Nrr1rdefaultr r r"gets z Mapping.getcCs,z ||Wntk r"YdSXdSdSr_rrr r r"r[s  zMapping.__contains__cCst|S)z:D.keys() -> a set-like object providing a view on D's keys)rr0r r r"keyssz Mapping.keyscCst|S)z a set-like object providing a view on D's items)rr0r r r"itemssz Mapping.itemscCst|S)z6D.values() -> an object providing a view on D's values)rr0r r r"valuesszMapping.valuescCs&t|tstSt|t|kSr!)rarr(dictrrhr r r"rls zMapping.__eq__)N) r6r7r8r9rrrr[rrrrlrWr r r r"rs   c@s(eZdZdZddZddZddZdS) r_mappingcCs ||_dSr!r)r1mappingr r r"__init__szMappingView.__init__cCs t|jSr!)rbrr0r r r"rXszMappingView.__len__cCs d|S)Nz&{0.__class__.__name__}({0._mapping!r}))formatr0r r r"__repr__szMappingView.__repr__N)r6r7r8r9rrXrr r r r"rsc@s,eZdZdZeddZddZddZdS) rr cCst|Sr!setr1rmr r r"rnszKeysView._from_iterablecCs ||jkSr!rrr r r"r[szKeysView.__contains__ccs|jEdHdSr!rr0r r r"rUszKeysView.__iter__Nr6r7r8r9r:rnr[rUr r r r"rs  c@s,eZdZdZeddZddZddZdS) rr cCst|Sr!rrr r r"rnszItemsView._from_iterablecCsB|\}}z|j|}Wntk r,YdSX||kp<||kSdSrY)rr)r1itemrr@vr r r"r[s zItemsView.__contains__ccs |jD]}||j|fVqdSr!rrr r r"rUs zItemsView.__iter__Nrr r r r"rs   c@s eZdZdZddZddZdS)rr cCs0|jD]$}|j|}||ks$||krdSqdSNTFr)r1r@rrr r r"r[s   zValuesView.__contains__ccs|jD]}|j|VqdSr!rrr r r"rUs zValuesView.__iter__N)r6r7r8r9r[rUr r r r"rsc@s^eZdZdZeddZeddZeZefddZ dd Z d d Z dd d Z dddZ dS)rr cCstdSr!rr1rr@r r r" __setitem__ szMutableMapping.__setitem__cCstdSr!rrr r r" __delitem__szMutableMapping.__delitem__cCs@z ||}Wn$tk r0||jkr(|YSX||=|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)r1rrr@r r r"rs   zMutableMapping.popcCsBztt|}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)rrr>rrr r r"popitem$s zMutableMapping.popitemcCs(z|qWntk r"YnXdS)z,D.clear() -> None. Remove all items from D.N)rrr0r r r"r0szMutableMapping.clearcKs|t|tr"|D]}||||<qn 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 rN)rarhasattrrr)r1rdr]rr@r r r"update8s     zMutableMapping.updateNcCs,z ||WStk r&|||<YnX|S)z@D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in Drrr r r" setdefaultJs  zMutableMapping.setdefault)r )N)r6r7r8r9rrrobjectrrrrrrr 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 cCstdSr! IndexErrorr1indexr r r"rbszSequence.__getitem__ccs<d}z||}|V|d7}qWntk r6YdSXdS)Nrrr)r1irr r r"rUfszSequence.__iter__cCs$|D]}||ks||krdSqdSrr )r1r@rr r r"r[pszSequence.__contains__ccs$ttt|D]}||VqdSr!)reversedrangerb)r1rr r r"rWvszSequence.__reversed__rNcCs|dk r"|dkr"tt||d}|dk r>|dkr>|t|7}|}|dksR||krz"||}||ksl||krr|WSWntk rYqYnX|d7}qBtdS)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)maxrbr ValueError)r1r@startstoprrr r r"rzs    zSequence.indexcstfdd|DS)zBS.count(value) -> integer -- return number of occurrences of valuec3s"|]}|ks|krdVqdS)rNr )rprr@r r"rqsz!Sequence.count..)sumr?r rr"countszSequence.count)rN) r6r7r8rr9rrrUr[rWrrr r r r"rXs   c@seZdZdZdZdS)rzMThis unifies bytes and bytearray. XXX Should add all their methods. r N)r6r7r8rr9r r r r"rsc@sneZdZdZeddZeddZeddZdd Zd d Z d d Z ddZ dddZ ddZ ddZdS)rr cCstdSr!rr1rr@r r r"rszMutableSequence.__setitem__cCstdSr!rrr r r"rszMutableSequence.__delitem__cCstdS)z3S.insert(index, value) -- insert value before indexNrrr r r"insertszMutableSequence.insertcCs|t||dS)z:S.append(value) -- append value to the end of the sequenceN)rrbr?r r r"appendszMutableSequence.appendcCs(z|qWntk r"YnXdS)z,S.clear() -> None -- remove all items from SN)rrr0r r r"rszMutableSequence.clearcCsHt|}t|dD].}|||d||||<|||d<qdS)z!S.reverse() -- reverse *IN PLACE*r~rN)rbr)r1rrr r r"reverseszMutableSequence.reversecCs(||krt|}|D]}||qdS)zMS.extend(iterable) -- extend sequence by appending elements from the iterableN)listr)r1rrr r r"extendszMutableSequence.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 )r1rrr r r"rszMutableSequence.popcCs|||=dS)zvS.remove(value) -- remove first occurrence of value. Raise ValueError if the value is not present. N)rr?r r r"rszMutableSequence.removecCs|||Sr!)r)r1rr r r"__iadd__s zMutableSequence.__iadd__N)r)r6r7r8r9rrrrrrrrrrrr r r r"rs     )Krabcrrr__all__r6typerbytes_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$ coroutinerMr%async_generatorr.r rrregisterrrrr r r r rrrrr frozensetrrrrrrrrrtuplestr memoryviewrbytesrrr r r r"s         ) 0              /   O 2    S =      C