a `r@sdZddlmZmZddlZeeeZedZ ddZ ee Z [ gdZ dZ eed ZeeeZeeiZeeiZeeiZeegZeeegZeeedZeeed d >ZeeeZeed Z eed Z!eee"Z#eiZ$eiZ%eiZ&eej'Z(eddZ)ddZ*e*Z*ee*Z+e*,[*ddZ-e-Z-ee-Z.[-ddZ/GdddedZ0GdddedZ1Gddde1Z2e23e+GdddedZ4Gdd d e4Z5Gd!d"d"e5Z6e63e.Gd#d$d$edZ7Gd%d&d&e7Z8e83ee83ee83ee83ee83ee83ee83ee83ee83ee83ee83e e83e!e83e#Gd'd(d(e7Z9Gd)d*d*e8Z:e:3e)Gd+d,d,edZ;Gd-d.d.edZd3d4Z?Gd5d6d6edZ@Gd7d8d8e=ZAeA3eBGd9d:d:eAZCeC3eGd;d<dd>e;ZEGd?d@d@eEeAZFeF3e$GdAdBdBeEeAZGeG3e&GdCdDdDeEe=ZHeH3e%GdEdFdFeDZIeI3eJGdGdHdHe9e=ZKeK3eLeK3eMeK3eeK3eNGdIdJdJeKZOeO3ePeO3eGdKdLdLeKZQeQ3eeQ3edS)MzjAbstract Base Classes (ABCs) for collections, according to PEP 3119. Unit tests are in test_collections. )ABCMetaabstractmethodN.cCsdSNrrr3/usr/local/src/Python-3.9.6/Lib/_collections_abc.py_fr) Awaitable Coroutine AsyncIterable AsyncIteratorAsyncGeneratorHashableIterableIterator Generator ReversibleSized ContainerCallable CollectionSet MutableSetMappingMutableMapping MappingViewKeysView ItemsView ValuesViewSequenceMutableSequence ByteStringzcollections.abcrirccsdVSrrrrrr>rr$csdSrrrrrr_coro@rr%cCs dVdSrrrrrr_agFrr&cGsN|j}|D]>}|D],}||jvr|j|dur:tSq qtSq dS)NT)__mro____dict__NotImplemented)CZmethodsmromethodBrrr_check_methodsNs   r.c@s(eZdZdZeddZeddZdS)rrcCsdSNrrselfrrr__hash__^szHashable.__hash__cCs|turt|dStS)Nr2)rr.r)clsr*rrr__subclasshook__bs zHashable.__subclasshook__N)__name__ __module__ __qualname__ __slots__rr2 classmethodr5rrrrrZs  r) metaclassc@s0eZdZdZeddZeddZeeZ dS)r rccs dVdSrrr0rrr __await__mszAwaitable.__await__cCs|turt|dStS)Nr<)r r.r)r3rrrr5qs zAwaitable.__subclasshook__N) r6r7r8r9rr<r:r5 GenericAlias__class_getitem__rrrrr is   r c@s>eZdZdZeddZed ddZddZed d Z dS) r rcCstdS)zcSend a value into the coroutine. Return next yielded value or raise StopIteration. N StopIterationr1valuerrrsend~szCoroutine.sendNcCs4|dur|dur||}|dur,||}|dS)zgRaise an exception in the coroutine. Return next yielded value or raise StopIteration. Nwith_tracebackr1typvaltbrrrthrows zCoroutine.throwc Cs2z|tWnttfy$Yn 0tddS).Raise GeneratorExit inside coroutine. zcoroutine ignored GeneratorExitNrJ GeneratorExitr@ RuntimeErrorr0rrrcloses zCoroutine.closecCs|turt|ddddStS)Nr<rCrJrO)r r.r)r3rrrr5szCoroutine.__subclasshook__)NN) r6r7r8r9rrCrJrOr:r5rrrrr zs   r c@s0eZdZdZeddZeddZeeZ dS)r rcCstSr)r r0rrr __aiter__szAsyncIterable.__aiter__cCs|turt|dStS)NrP)r r.r)r3rrrr5s zAsyncIterable.__subclasshook__N) r6r7r8r9rrPr:r5r=r>rrrrr s   r c@s0eZdZdZeddZddZeddZdS) r rcstdS)z@Return the next item or raise StopAsyncIteration when exhausted.NStopAsyncIterationr0rrr __anext__szAsyncIterator.__anext__cCs|Srrr0rrrrPszAsyncIterator.__aiter__cCs|turt|ddStS)NrSrP)r r.r)r3rrrr5s zAsyncIterator.__subclasshook__N) r6r7r8r9rrSrPr:r5rrrrr s  r c@sFeZdZdZddZeddZed ddZd d Ze d d Z dS)r rcs|dIdHS)zpReturn the next item from the asynchronous generator. When exhausted, raise StopAsyncIteration. N)asendr0rrrrSszAsyncGenerator.__anext__cstdS)zuSend a value into the asynchronous generator. Return next yielded value or raise StopAsyncIteration. NrQrArrrrTszAsyncGenerator.asendNcs4|dur|dur||}|dur,||}|dS)zyRaise an exception in the asynchronous generator. Return next yielded value or raise StopAsyncIteration. NrDrFrrrathrows zAsyncGenerator.athrowc s8z|tIdHWnttfy*Yn 0tddS)rKNz,asynchronous generator ignored GeneratorExit)rUrMrRrNr0rrracloses zAsyncGenerator.aclosecCs|turt|dddddStS)NrPrSrTrUrV)r r.r)r3rrrr5s zAsyncGenerator.__subclasshook__)NN) r6r7r8r9rSrrTrUrVr:r5rrrrr s   r c@s0eZdZdZeddZeddZeeZ dS)rrccsdSrrr0rrr__iter__szIterable.__iter__cCs|turt|dStS)NrW)rr.r)r3rrrr5s zIterable.__subclasshook__N) r6r7r8r9rrWr:r5r=r>rrrrrs   rc@s0eZdZdZeddZddZeddZdS) rrcCstdS)zKReturn the next item from the iterator. When exhausted, raise StopIterationNr?r0rrr__next__szIterator.__next__cCs|Srrr0rrrrWszIterator.__iter__cCs|turt|ddStS)NrWrX)rr.r)r3rrrr5s zIterator.__subclasshook__N) r6r7r8r9rrXrWr:r5rrrrrs  rc@s(eZdZdZeddZeddZdS)rrccsdSrrr0rrr __reversed__6szReversible.__reversed__cCs|turt|ddStS)NrYrW)rr.r)r3rrrr5;s zReversible.__subclasshook__N)r6r7r8r9rrYr:r5rrrrr2s  rc@sFeZdZdZddZeddZed ddZd d Ze d d Z dS)rrcCs |dS)z^Return the next item from the generator. When exhausted, raise StopIteration. N)rCr0rrrrXFszGenerator.__next__cCstdS)zcSend a value into the generator. Return next yielded value or raise StopIteration. Nr?rArrrrCLszGenerator.sendNcCs4|dur|dur||}|dur,||}|dS)zgRaise an exception in the generator. Return next yielded value or raise StopIteration. NrDrFrrrrJSs zGenerator.throwc Cs2z|tWnttfy$Yn 0tddS)z.Raise GeneratorExit inside generator. zgenerator ignored GeneratorExitNrLr0rrrrO`s zGenerator.closecCs|turt|dddddStS)NrWrXrCrJrO)rr.r)r3rrrr5js zGenerator.__subclasshook__)NN) r6r7r8r9rXrrCrJrOr:r5rrrrrBs   rc@s(eZdZdZeddZeddZdS)rrcCsdSr/rr0rrr__len__ysz Sized.__len__cCs|turt|dStS)NrZ)rr.r)r3rrrr5}s zSized.__subclasshook__N)r6r7r8r9rrZr:r5rrrrrus  rc@s0eZdZdZeddZeddZeeZ dS)rrcCsdSNFr)r1xrrr __contains__szContainer.__contains__cCs|turt|dStS)Nr])rr.r)r3rrrr5s zContainer.__subclasshook__N) r6r7r8r9rr]r:r5r=r>rrrrrs   rc@seZdZdZeddZdS)rrcCs|turt|dddStS)NrZrWr])rr.r)r3rrrr5szCollection.__subclasshook__N)r6r7r8r9r:r5rrrrrsrcsPeZdZdZdZddZefddZfddZd d Z fd d Z Z S) _CallableGenericAliasz Represent `Callable[argtypes, resulttype]`. This sets ``__args__`` to a tuple containing the flattened``argtypes`` followed by ``resulttype``. Example: ``Callable[[int, str], float]`` sets ``__args__`` to ``(int, str, float)``. rc Cs`z|||WStyZ}z4ddl}|t|dtt||WYd}~Sd}~00dS)Nrz. (This will raise a TypeError in Python 3.10.)) _CallableGenericAlias__create_ga TypeErrorwarningswarnstrDeprecationWarningr=)r4originargsexcrarrr__new__sz_CallableGenericAlias.__new__csXt|trt|dkrtd|\}}t|ttfrDt||f}n|}t|||S)Nz6Callable must be used as Callable[[arg, ...], result].) isinstancetuplelenr`listsuperrh)r4rerft_argst_resultZga_args __class__rrZ __create_gasz!_CallableGenericAlias.__create_gacs\t|jdkr&|jdtur&tSdddd|jddDdt|jdd S) Nrirzcollections.abc.Callable[[z, cSsg|] }t|qSr) _type_repr).0arrr rz2_CallableGenericAlias.__repr__..z], ])rl__args__Ellipsisrn__repr__joinrsr0rqrrr{s  z_CallableGenericAlias.__repr__cCsB|j}t|dkr|dtus6t|dd|df}tt|ffS)Nrirrw)ryrlrzrmr^r)r1rfrrr __reduce__sz _CallableGenericAlias.__reduce__cs8t|}|j}|d}|dd}||f}tt|S)Nrw)rn __getitem__ryr^r)r1itemZgarfrprorqrrr~s   z!_CallableGenericAlias.__getitem__) r6r7r8__doc__r9rhr:r_r{r}r~ __classcell__rrrqrr^s   r^cCsbt|trt|St|tr>|jdkr,|jS|jd|jS|turJdSt|trZ|jSt|S)zReturn the repr() of an object, special-casing types (internal helper). Copied from :mod:`typing` since collections.abc shouldn't depend on that module. builtins.z...) rjr=reprtyper7r8rz FunctionTyper6)objrrrrss    rsc@s0eZdZdZeddZeddZeeZ dS)rrcOsdSr[r)r1rfkwdsrrr__call__szCallable.__call__cCs|turt|dStS)Nr)rr.r)r3rrrr5s zCallable.__subclasshook__N) r6r7r8r9rrr:r5r^r>rrrrrs   rc@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. rcCs>t|tstSt|t|kr"dS|D]}||vr&dSq&dSNFTrjrr)rlr1otherelemrrr__le__s z Set.__le__cCs(t|tstSt|t|ko&||Srrjrr)rlrr1rrrr__lt__s z Set.__lt__cCs(t|tstSt|t|ko&||Sr)rjrr)rl__ge__rrrr__gt__!s z Set.__gt__cCs>t|tstSt|t|kr"dS|D]}||vr&dSq&dSrrrrrrr&s z Set.__ge__cCs(t|tstSt|t|ko&||Srrrrrr__eq__0s 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)r4itrrr_from_iterable5szSet._from_iterablecs&t|tstSfdd|DS)Nc3s|]}|vr|VqdSrrrtrBr0rr ArzSet.__and__..rjrr)rrrr0r__and__>s z Set.__and__cCs|D]}||vrdSqdS)z1Return True if two sets have a null intersection.FTr)r1rrBrrr isdisjointEszSet.isdisjointcCs*t|tstSdd||fD}||S)Ncss|]}|D] }|Vq qdSrr)rtserrrrOrzSet.__or__..r)r1rchainrrr__or__Ls z Set.__or__cs:tts"ttstS||fdd|DS)Nc3s|]}|vr|VqdSrrrrrrrYszSet.__sub__..rjrrr)rrrrr__sub__Ts    z Set.__sub__cs:t|ts"t|tstS|}fdd|DS)Nc3s|]}|vr|VqdSrrrr0rrraszSet.__rsub__..rrrr0r__rsub__\s    z Set.__rsub__cCs2t|ts"t|tstS||}||||BSrrrrrr__xor__ds    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. rir"iMriM[l4~2i i6rwi8#)sysmaxsizerlhash)r1ZMAXZMASKnhr\Zhxrrr_hashms      z Set._hashN)r6r7r8rr9rrrrrr:rr__rand__rr__ror__rrr__rxor__rrrrrrs&    rc@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. rcCstdS)zAdd an element.NNotImplementedErrorrArrraddszMutableSet.addcCstdS)z8Remove an element. Do not raise an exception if absent.NrrArrrdiscardszMutableSet.discardcCs||vrt|||dS)z5Remove an element. If not a member, raise a KeyError.N)KeyErrorrrArrrremoveszMutableSet.removecCs<t|}z t|}Wnty,tdYn0|||S)z2Return the popped value. Raise KeyError if empty.N)iternextr@rrr1rrBrrrpops    zMutableSet.popcCs&z|qWnty Yn0dS)z6This is slow (creates N new iterators!) but effective.N)rrr0rrrclears zMutableSet.clearcCs|D]}||q|Sr)rrrrr__ior__s zMutableSet.__ior__cCs||D]}||q|Sr)rrrrr__iand__s  zMutableSet.__iand__cCsR||ur|n D[k] if k in D, else d. d defaults to None.Nrr1rdefaultrrrgets  z Mapping.getcCs*z ||Wnty YdS0dSdSrrrrrrr]s   zMapping.__contains__cCst|S)z:D.keys() -> a set-like object providing a view on D's keys)rr0rrrkeyssz Mapping.keyscCst|S)z a set-like object providing a view on D's items)rr0rrritems sz Mapping.itemscCst|S)z6D.values() -> an object providing a view on D's values)rr0rrrvaluesszMapping.valuescCs&t|tstSt|t|kSr)rjrr)dictrrrrrrs zMapping.__eq__)N) r6r7r8r9rr~rr]rrrrrYrrrrrs   rc@s0eZdZdZddZddZddZeeZ dS) r_mappingcCs ||_dSrr)r1mappingrrr__init__!szMappingView.__init__cCs t|jSr)rlrr0rrrrZ$szMappingView.__len__cCs d|S)Nz&{0.__class__.__name__}({0._mapping!r}))formatr0rrrr{'szMappingView.__repr__N) r6r7r8r9rrZr{r:r=r>rrrrrs rc@s,eZdZdZeddZddZddZdS) rrcCst|Srsetr1rrrrr1szKeysView._from_iterablecCs ||jvSrrrrrrr]5szKeysView.__contains__ccs|jEdHdSrrr0rrrrW8szKeysView.__iter__Nr6r7r8r9r:rr]rWrrrrr-s  rc@s,eZdZdZeddZddZddZdS) rrcCst|SrrrrrrrCszItemsView._from_iterablecCs@|\}}z|j|}Wnty*YdS0||up:||kSdSr[)rr)r1rrrBvrrrr]Gs  zItemsView.__contains__ccs |jD]}||j|fVqdSrrrrrrrWPs zItemsView.__iter__Nrrrrrr?s   rc@s eZdZdZddZddZdS)rrcCs0|jD]$}|j|}||us$||krdSqdSNTFr)r1rBrrrrrr]\s   zValuesView.__contains__ccs|jD]}|j|VqdSrrrrrrrWcs zValuesView.__iter__N)r6r7r8r9r]rWrrrrrXsrc@s^eZdZdZeddZeddZeZefddZ dd Z d d Z dd d Z dddZ dS)rrcCstdSrrr1rrBrrr __setitem__xszMutableMapping.__setitem__cCstdSrrrrrr __delitem__|szMutableMapping.__delitem__cCs>z ||}Wn"ty.||jur&|YS0||=|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)r1rrrBrrrrs    zMutableMapping.popcCs@ztt|}Wnty(tdYn0||}||=||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@rrrrrpopitems  zMutableMapping.popitemcCs&z|qWnty Yn0dS)z,D.clear() -> None. Remove all items from D.N)rrr0rrrrs zMutableMapping.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)rjrhasattrrr)r1rrrrBrrrupdates     zMutableMapping.updateNcCs*z ||WSty$|||<Yn0|S)z@D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in Drrrrr setdefaults   zMutableMapping.setdefault)r)N)r6r7r8r9rrrobjectrrrrrrrrrrrks      rc@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__. rcCstdSr IndexErrorr1indexrrrr~szSequence.__getitem__ccs:d}z||}|V|d7}qWnty4YdS0dS)Nrr"r)r1irrrrrWs zSequence.__iter__cCs$|D]}||us||krdSqdSrr)r1rBrrrrr]szSequence.__contains__ccs$ttt|D]}||VqdSr)reversedrangerl)r1rrrrrYszSequence.__reversed__rNcCs|dur"|dkr"tt||d}|dur>|dkr>|t|7}|}|dusR||krz"||}||usl||krr|WSWntyYqYn0|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")maxrlr ValueError)r1rBstartstoprrrrrrs     zSequence.indexcstfdd|DS)zBS.count(value) -> integer -- return number of occurrences of valuec3s"|]}|us|krdVqdS)r"Nr)rtrrBrrrrz!Sequence.count..)sumrArrrcountszSequence.count)rN) r6r7r8rr9rr~rWr]rYrrrrrrrs   rc@seZdZdZdZdS)r!zMThis unifies bytes and bytearray. XXX Should add all their methods. rN)r6r7r8rr9rrrrr! sr!c@sneZdZdZeddZeddZeddZdd Zd d Z d d Z ddZ dddZ ddZ ddZdS)r rcCstdSrrr1rrBrrrr!szMutableSequence.__setitem__cCstdSrrrrrrr%szMutableSequence.__delitem__cCstdS)z3S.insert(index, value) -- insert value before indexNrrrrrinsert)szMutableSequence.insertcCs|t||dS)z:S.append(value) -- append value to the end of the sequenceN)rrlrArrrappend.szMutableSequence.appendcCs&z|qWnty Yn0dS)z,S.clear() -> None -- remove all items from SN)rrr0rrrr2s zMutableSequence.clearcCsHt|}t|dD].}|||d||||<|||d<qdS)z!S.reverse() -- reverse *IN PLACE*rir"N)rlr)r1rrrrrreverse:szMutableSequence.reversecCs(||urt|}|D]}||qdS)zMS.extend(iterable) -- extend sequence by appending elements from the iterableN)rmr)r1rrrrrextend@szMutableSequence.extendrwcCs||}||=|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)r1rrrrrrGszMutableSequence.popcCs|||=dS)zvS.remove(value) -- remove first occurrence of value. Raise ValueError if the value is not present. N)rrArrrrOszMutableSequence.removecCs|||Sr)r)r1rrrr__iadd__Us zMutableSequence.__iadd__N)rw)r6r7r8r9rrrrrrrrrrrrrrrr s     r )Rrabcrrrrrmintr=Z EllipsisTyperr__all__r6rZbytes_iterator bytearrayZbytearray_iteratorrZdict_keyiteratorrZdict_valueiteratorrZdict_itemiteratorZ list_iteratorrZlist_reverseiteratorrZrange_iteratorZlongrange_iteratorrZ set_iteratorZ str_iteratorZtuple_iteratorzipZ zip_iteratorZ dict_keysZ dict_valuesZ dict_itemsr(Z mappingproxyZ generatorr% coroutinerOr&Zasync_generatorr.rr r registerr r r rrrrrrrr^rsrr frozensetrrrrrrrrrrkrc memoryviewr!bytesr rrrrs          ) 0              0  = P 3    T >      D