f _@sdZgdZddlZddlZddlmZddlmZ ddlm Z ddl m ZddlmZdd lmZdd lmZdd lmZzdd lmZWneyYn0ejezdd lmZWneyYn0ddZ Gdddej!Z"Gdddej#Z$Gdddej%Z&Gddde'Z(Gddde)Z*zddlm*Z*WneyRYn0zddlm+Z+WneyddZ+Yn0ddddd d!Z,d"d#Z-zdd$lm-Z-WneyYn0Gd%d&d&e)Z.Gd'd(d(ej/Z0Gd)d*d*ej/Z1Gd+d,d,ejZ2Gd-d.d.ej3Z4dS)/a?This module implements specialized container datatypes providing alternatives to Python's general purpose built-in containers, dict, list, set, and tuple. * namedtuple factory function for creating tuple subclasses with named fields * deque list-like container with fast appends and pops on either end * ChainMap dict-like class for creating a single view of multiple mappings * Counter dict subclass for counting hashable objects * OrderedDict dict subclass that remembers the order entries were added * defaultdict dict subclass that calls a factory function to supply missing values * UserDict wrapper around dictionary objects for easier dict subclassing * UserList wrapper around list objects for easier list subclassing * UserString wrapper around string objects for easier string subclassing ) ChainMapCounter OrderedDictUserDictUserList UserString defaultdictdeque namedtupleN)chain)repeat)starmap) iskeyword)eq) itemgetter)recursive_repr)proxy)r)rcCsR|tjvr:tt|}ddl}|jdtdd|t|<|Stdtd|dS)Nr zUsing or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working) stacklevelzmodule z has no attribute ) _collections_abc__all__getattrwarningswarnDeprecationWarningglobalsAttributeError__name__)nameobjrr -/usr/lib64/python3.10/collections/__init__.py __getattr__6s   r"c@seZdZddZdS)_OrderedDictKeysViewccst|jEdHdSNreversed_mappingselfr r r! __reversed__Lsz!_OrderedDictKeysView.__reversed__Nr __module__ __qualname__r*r r r r!r#Jsr#c@seZdZddZdS)_OrderedDictItemsViewccs$t|jD]}||j|fVq dSr$r%r)keyr r r!r*Qsz"_OrderedDictItemsView.__reversed__Nr+r r r r!r.Osr.c@seZdZddZdS)_OrderedDictValuesViewccs t|jD]}|j|Vq dSr$r%r/r r r!r*Wsz#_OrderedDictValuesView.__reversed__Nr+r r r r!r1Usr1c@seZdZdZdS)_Link)prevnextr0 __weakref__N)rr,r- __slots__r r r r!r2[sr2c@seZdZdZd1ddZejeefddZej fddZ d d Z d d Z d dZ d2ddZ d3ddZddZejjZZddZddZddZejjZeZefddZd4dd Zed!d"Zd#d$Zd%d&Ze d5d'd(Z!d)d*Z"d+d,Z#d-d.Z$d/d0Z%dS)6rz)Dictionary that remembers insertion orderr cKs^z |jWn<tyFt|_t|j|_}||_|_i|_Yn0|j|fi|dS)zInitialize an ordered dictionary. The signature is the same as regular dictionaries. Keyword argument order is preserved. N) _OrderedDict__rootrr2_OrderedDict__hardroot_proxyr3r4_OrderedDict__map_OrderedDict__update)r)otherkwdsrootr r r!__init__ms    zOrderedDict.__init__c CsZ||vrJ||j|<}|j}|j}||||_|_|_||_|||_||||dS)z!od.__setitem__(i, y) <==> od[i]=yN)r:r7r3r4r0) r)r0valueZ dict_setitemrZLinklinkr>lastr r r! __setitem__zs zOrderedDict.__setitem__cCs>||||j|}|j}|j}||_||_d|_d|_dS)z od.__delitem__(y) <==> del od[y]N)r:popr3r4)r)r0Z dict_delitemrA link_prev link_nextr r r! __delitem__s  zOrderedDict.__delitem__ccs(|j}|j}||ur$|jV|j}q dS)zod.__iter__() <==> iter(od)N)r7r4r0r)r>Zcurrr r r!__iter__s zOrderedDict.__iter__ccs(|j}|j}||ur$|jV|j}q dS)z#od.__reversed__() <==> reversed(od)N)r7r3r0rHr r r!r*s zOrderedDict.__reversed__cCs*|j}||_|_|jt|dS)z.od.clear() -> None. Remove all items from od.N)r7r3r4r:cleardict)r)r>r r r!rJs  zOrderedDict.clearTcCsj|s td|j}|r0|j}|j}||_||_n|j}|j}||_||_|j}|j|=t||}||fS)zRemove and return a (key, value) pair from the dictionary. Pairs are returned in LIFO order if last is true or FIFO order if false. zdictionary is empty)KeyErrorr7r3r4r0r:rKrD)r)rBr>rArErFr0r@r r r!popitems  zOrderedDict.popitemc Cst|j|}|j}|j}|j}||_||_|j}|rR|j}||_||_||_||_n|j}||_||_||_||_dS)zMove an existing element to the end (or beginning if last is false). Raise KeyError if the element does not exist. N)r:r3r4r7) r)r0rBrArErFZ soft_linkr>firstr r r! move_to_ends$ zOrderedDict.move_to_endcCsVtj}t|d}||j}|||jd7}|||j|7}|||j|7}|S)Nr)_sys getsizeoflen__dict__r:r8r7)r)Zsizeofnsizer r r! __sizeof__s  zOrderedDict.__sizeof__cCst|S)z:D.keys() -> a set-like object providing a view on D's keys)r#r(r r r!keysszOrderedDict.keyscCst|S)z a set-like object providing a view on D's items)r.r(r r r!itemsszOrderedDict.itemscCst|S)z6D.values() -> an object providing a view on D's values)r1r(r r r!valuesszOrderedDict.valuescCs0||vr||}||=|S||jur,t||S)zod.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. )_OrderedDict__markerrL)r)r0defaultresultr r r!rDs zOrderedDict.popNcCs||vr||S|||<|S)zInsert key with a value of default if key is not in the dictionary. Return the value for key if key is in the dictionary, else default. r r)r0r\r r r! setdefaultszOrderedDict.setdefaultcCs*|sd|jjfSd|jjt|fS)zod.__repr__() <==> repr(od)z%s()z%s(%r)) __class__rlistrYr(r r r!__repr__szOrderedDict.__repr__cCsDt|}ttD]}||dq|jd|p4ddt|fS)z%Return state information for picklingNr )varscopyrrDr`iterrY)r) inst_dictkr r r! __reduce__s zOrderedDict.__reduce__cCs ||S)z!od.copy() -> a shallow copy of odr`r(r r r!rdszOrderedDict.copycCs|}|D] }|||<q |S)zYCreate a new ordered dictionary with keys from iterable and values set to value. r )clsiterabler@r)r0r r r!fromkeys#s zOrderedDict.fromkeyscCs2t|tr&t||o$ttt||St||S)zod.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive. ) isinstancerrK__eq__allmap_eqr)r<r r r!rn,s zOrderedDict.__eq__cCs|||Sr$)updaterrr r r!__ior__5s zOrderedDict.__ior__cCs&t|tstS||}|||Sr$rmrKNotImplementedr`rsr)r<newr r r!__or__9s    zOrderedDict.__or__cCs&t|tstS||}|||Sr$rurwr r r!__ror__@s    zOrderedDict.__ror__)r )T)T)N)N)&rr,r-__doc__r?rKrCr9r2rGrIr*rJrMrOrWrMutableMappingrsr;rXrYrZ__ne__objectr[rDr__recursive_reprrbrhrd classmethodrlrnrtryrzr r r r!r^s:             r)r) _tuplegettercCstt||dS)N)doc)property _itemgetter)indexrr r r!VrF)renamedefaultsmodulec sttrddttttt|}|rt}t D]B\}}| rrt |sr| dsr||vrd||<| |qH|gD]D}t|turtd| std|t |rtd|qt}D]F}| dr |s td|||vr"td|| |qi}|d ur|t|}t|tkr^td tttttt|}tttjtd } d kr| d7} d d ddDdtjtttttf\d d|d} d| d| d} t| | } d| _d|d | d| _|d urB|| _tfdd} d|d| j_fdd}d|d|_fd d!}fd"d#}fd$d%}| | j||||fD]}|d&|j|_q|d | dd'|| | ||||d( }t D](\}}td)|}t||||<qt|tf|}|d urvzt d j!"d*d+}Wnt#tfytYn0|d ur||_$|S),aCReturns a new subclass of tuple with named fields. >>> Point = namedtuple('Point', ['x', 'y']) >>> Point.__doc__ # docstring for the new class 'Point(x, y)' >>> p = Point(11, y=22) # instantiate with positional args or keywords >>> p[0] + p[1] # indexable like a plain tuple 33 >>> x, y = p # unpack like a regular tuple >>> x, y (11, 22) >>> p.x + p.y # fields also accessible by name 33 >>> d = p._asdict() # convert to a dictionary >>> d['x'] 11 >>> Point(**d) # convert from a dictionary Point(x=11, y=22) >>> p._replace(x=100) # _replace() is like str.replace() but targets named fields Point(x=100, y=22) , _z*Type names and field names must be stringsz6Type names and field names must be valid identifiers: z0Type names and field names cannot be a keyword: z-Field names cannot start with an underscore: z"Encountered duplicate field name: Nz(Got more default values than field names, rP(css|]}|dVqdS)z=%rNr ).0rr r r! rznamedtuple..) namedtuple_) _tuple_new __builtins__rz lambda _cls, z: _tuple_new(_cls, (z))__new__zCreate new instance of cs2||}|kr.tddt||S)Nz Expected z arguments, got ) TypeErrorrS)rjrkr])_len num_fields tuple_newr r!_makes  znamedtuple.._makez Make a new z# object from a sequence or iterablecs.||j|}|r*tdt||S)NzGot unexpected field names: )rrD ValueErrorra)r)r=r])_map field_namesr r!_replacesznamedtuple.._replacez Return a new z2 object replacing specified fields with new valuescs|jj|S)z/Return a nicely formatted representation string)r`rr()repr_fmtr r!rbsznamedtuple..__repr__cs|j|S)z9Return a new dict which maps field names to their values.)_fieldsr()_dict_zipr r!_asdictsznamedtuple.._asdictcs|S)z7Return self as a plain tuple. Used by copy and pickle.r r()_tupler r!__getnewargs__sz"namedtuple..__getnewargs__.r ) r{r6r_field_defaultsrrrrbrrzAlias for field number r__main__)%rmstrreplacesplitrarprQinternset enumerate isidentifier _iskeyword startswithaddtyperrtuplerSrKr&zipjoinrevalrr{ __defaults__r__func__r-r _getframe f_globalsgetrr,)typenamerrrrseenrrfield_defaultsarg_list namespacecoderrrrbrrmethodclass_namespacerr]r ) rrrrrrrrrr!r Xs                 r cCs&|j}|D]}||dd||<q dS)z!Tally elements from the iterable.r rPN)r)mappingrkZ mapping_getelemr r r!_count_elementssr)rcseZdZdZd;fdd ZddZdfd d Z d?ddZ ddZ ddZ fddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Z Z!S)@raDict subclass for counting hashable items. Sometimes called a bag or multiset. Elements are stored as dictionary keys and their counts are stored as dictionary values. >>> c = Counter('abcdeabcdabcaba') # count elements from a string >>> c.most_common(3) # three most common elements [('a', 5), ('b', 4), ('c', 3)] >>> sorted(c) # list all unique elements ['a', 'b', 'c', 'd', 'e'] >>> ''.join(sorted(c.elements())) # list elements with repetitions 'aaaaabbbbcccdde' >>> sum(c.values()) # total of all counts 15 >>> c['a'] # count of letter 'a' 5 >>> for elem in 'shazam': # update counts from an iterable ... c[elem] += 1 # by adding 1 to each element's count >>> c['a'] # now there are seven 'a' 7 >>> del c['b'] # remove all 'b' >>> c['b'] # now there are zero 'b' 0 >>> d = Counter('simsalabim') # make another counter >>> c.update(d) # add in the second counter >>> c['a'] # now there are nine 'a' 9 >>> c.clear() # empty the counter >>> c Counter() Note: If a count is set to zero or reduced to zero, it will remain in the counter until the entry is deleted or the counter is cleared: >>> c = Counter('aaabbc') >>> c['b'] -= 2 # reduce the count of 'b' by two >>> c.most_common() # 'b' is still in, but its count is zero [('a', 3), ('c', 1), ('b', 0)] Nc s t|j|fi|dS)a Create a new, empty Counter object. And if given, count elements from an input iterable. Or, initialize the count from another mapping of elements to their counts. >>> c = Counter() # a new, empty counter >>> c = Counter('gallahad') # a new counter from an iterable >>> c = Counter({'a': 4, 'b': 2}) # a new counter from a mapping >>> c = Counter(a=4, b=2) # a new counter from keyword args N)superr?rs)r)rkr=rir r!r?Ds zCounter.__init__cCsdS)z1The count of elements not in the Counter is zero.r r r/r r r! __missing__RszCounter.__missing__cCs>|durt|tdddSddl}|j||tddS)zList the n most common elements and their counts from the most common to the least. If n is None, then list all element counts. >>> Counter('abracadabra').most_common(3) [('a', 5), ('b', 2), ('r', 2)] NrPT)r0reverser r0)sortedrYrheapqnlargest)r)rUrr r r! most_commonWs zCounter.most_commoncCsttt|S)aIterator over elements repeating each as many times as its count. >>> c = Counter('ABCABC') >>> sorted(c.elements()) ['A', 'A', 'B', 'B', 'C', 'C'] # Knuth's example for prime factors of 1836: 2**2 * 3**3 * 17**1 >>> prime_factors = Counter({2: 2, 3: 3, 17: 1}) >>> product = 1 >>> for factor in prime_factors.elements(): # loop over factors ... product *= factor # and multiply them >>> product 1836 Note, if an element's count has been set to zero or is a negative number, elements() will ignore it. )_chain from_iterable_starmap_repeatrYr(r r r!elementsgszCounter.elementscCs tddS)Nz@Counter.fromkeys() is undefined. Use Counter(iterable) instead.)NotImplementedError)rjrkvr r r!rls zCounter.fromkeysc sn|dur\t|tjrR|rD|j}|D]\}}|||d||<q&nt|n t|||rj||dS)aLike dict.update() but add counts instead of replacing them. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter('which') >>> c.update('witch') # add elements from another iterable >>> d = Counter('watch') >>> c.update(d) # add elements from another counter >>> c['h'] # four 'h' in which, witch, and watch 4 Nr )rmrMappingrrYrrsrr)rkr=self_getrcountrir r!rss  zCounter.updatecKsn|dur\|j}t|tjr@|D]\}}||d|||<q"n|D]}||dd||<qD|rj||dS)aLike dict.update() but subtracts counts instead of replacing them. Counts can be reduced below zero. Both the inputs and outputs are allowed to contain zero and negative counts. Source can be an iterable, a dictionary, or another Counter instance. >>> c = Counter('which') >>> c.subtract('witch') # subtract elements from another iterable >>> c.subtract(Counter('watch')) # subtract elements from another counter >>> c['h'] # 2 in which, minus 1 in witch, minus 1 in watch 0 >>> c['w'] # 1 in which, minus 1 in witch, minus 1 in watch -1 Nr rP)rrmrrrYsubtractrr r r!rs zCounter.subtractcCs ||S)zReturn a shallow copy.rir(r r r!rdsz Counter.copycCs|jt|ffSr$)r`rKr(r r r!rhszCounter.__reduce__cs||vrt|dS)zGLike dict.__delitem__() but does not raise KeyError for missing values.N)rrG)r)rrir r!rGszCounter.__delitem__cs*ttstStfddfDS)z=True if all counts agree. Missing counts are treated as zero.c3s(|] }|D]}||kVq qdSr$r rcer<r)r r!rrz!Counter.__eq__..rmrrvrorrr rr!rns zCounter.__eq__cCst|tstS||k S)z@True if any counts disagree. Missing counts are treated as zero.rmrrvrrr r r!r}s zCounter.__ne__cs*ttstStfddfDS)z:True if all counts in self are a subset of those in other.c3s(|] }|D]}||kVq qdSr$r rrr r!rrz!Counter.__le__..rrrr rr!__le__s zCounter.__le__cCst|tstS||ko||kS)zATrue if all counts in self are a proper subset of those in other.rrrr r r!__lt__s zCounter.__lt__cs*ttstStfddfDS)z.rrrr rr!__ge__s zCounter.__ge__cCst|tstS||ko||kS)zCTrue if all counts in self are a proper superset of those in other.rrrr r r!__gt__s zCounter.__gt__cCsR|s|jjdSzt|}Wnty<t|}Yn0|jjd|dS)Nz()rr)r`rrKrr)r)dr r r!rbs zCounter.__repr__cCspt|tstSt}|D]$\}}|||}|dkr|||<q|D] \}}||vrJ|dkrJ|||<qJ|S)zAdd counts from two counters. >>> Counter('abbb') + Counter('bcc') Counter({'b': 4, 'c': 2, 'a': 1}) r rmrrvrYr)r<r]rrnewcountr r r!__add__!s    zCounter.__add__cCstt|tstSt}|D]$\}}|||}|dkr|||<q|D]$\}}||vrJ|dkrJd|||<qJ|S)z Subtract count, but keep only results with positive counts. >>> Counter('abbbc') - Counter('bccd') Counter({'b': 2, 'a': 1}) r rrr r r!__sub__4s   zCounter.__sub__cCs|t|tstSt}|D]0\}}||}||kr8|n|}|dkr|||<q|D] \}}||vrV|dkrV|||<qV|S)zUnion is the maximum of value in either of the input counters. >>> Counter('abbb') | Counter('bcc') Counter({'b': 3, 'c': 2, 'a': 1}) r rr)r<r]rr other_countrr r r!ryGs   zCounter.__or__cCsRt|tstSt}|D]0\}}||}||kr8|n|}|dkr|||<q|S)z Intersection is the minimum of corresponding counts. >>> Counter('abbb') & Counter('bcc') Counter({'b': 1}) r rrr r r!__and__[s  zCounter.__and__cCs,t}|D]\}}|dkr|||<q|S)zEAdds an empty counter, effectively stripping negative and zero countsr rrYr)r]rrr r r!__pos__ls  zCounter.__pos__cCs0t}|D]\}}|dkrd|||<q|S)z{Subtracts from an empty counter. Strips positive and zero counts, and flips the sign on negative counts. r rrr r r!__neg__ts zCounter.__neg__cCs&dd|D}|D] }||=q|S)z?Internal method to strip elements with a negative or zero countcSsg|]\}}|dks|qS)r r )rrrr r r! rz*Counter._keep_positive..)rY)r) nonpositiverr r r!_keep_positiveszCounter._keep_positivecCs*|D]\}}|||7<q|S)zInplace add from another counter, keeping only positive counts. >>> c = Counter('abbb') >>> c += Counter('bcc') >>> c Counter({'b': 4, 'c': 2, 'a': 1}) rYrr)r<rrr r r!__iadd__s zCounter.__iadd__cCs*|D]\}}|||8<q|S)zInplace subtract counter, but keep only results with positive counts. >>> c = Counter('abbbc') >>> c -= Counter('bccd') >>> c Counter({'b': 2, 'a': 1}) rrr r r!__isub__s zCounter.__isub__cCs2|D] \}}||}||kr|||<q|S)zInplace union is the maximum of value from either counter. >>> c = Counter('abbb') >>> c |= Counter('bcc') >>> c Counter({'b': 3, 'c': 2, 'a': 1}) r)r)r<rrrr r r!rts  zCounter.__ior__cCs2|D] \}}||}||kr|||<q|S)zInplace intersection is the minimum of corresponding counts. >>> c = Counter('abbb') >>> c &= Counter('bcc') >>> c Counter({'b': 1}) r)r)r<rrrr r r!__iand__s  zCounter.__iand__)N)N)N)N)N)"rr,r-r{r?rrrrrlrsrrdrhrGrnr}rrrrrbrrryrrrrrrrtr __classcell__r r rir!rs<2  "  )   rc@seZdZdZddZddZddZd-d d Zd d Zd dZ ddZ ddZ e ddZ eddZddZeZd.ddZeddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,ZdS)/ra A ChainMap groups multiple dicts (or other mappings) together to create a single, updateable view. The underlying mappings are stored in a list. That list is public and can be accessed or updated using the *maps* attribute. There is no other state. Lookups search the underlying mappings successively until a key is found. In contrast, writes, updates, and deletions only operate on the first mapping. cGst|p ig|_dS)zInitialize a ChainMap by setting *maps* to the given mappings. If no mappings are provided, a single empty dictionary is used. N)ramaps)r)rr r r!r?szChainMap.__init__cCs t|dSr$)rLr/r r r!rszChainMap.__missing__c Cs6|jD]$}z||WSty*Yq0||Sr$)rrLr)r)r0rr r r! __getitem__s   zChainMap.__getitem__NcCs||vr||S|Sr$r r^r r r!rsz ChainMap.getcCsttj|jSr$)rSrunionrr(r r r!__len__szChainMap.__len__cCs&i}t|jD]}||qt|Sr$)r&rrsre)r)rrr r r!rIs zChainMap.__iter__cstfdd|jDS)Nc3s|]}|vVqdSr$r )rmrr r!rrz(ChainMap.__contains__..anyrr/r rr! __contains__szChainMap.__contains__cCs t|jSr$rr(r r r!__bool__szChainMap.__bool__cCs"|jjddtt|jdS)Nrrr)r`rrrpreprrr(r r r!rbszChainMap.__repr__cGs|tj|g|RS)z?Create a ChainMap with a single dict created from the iterable.)rKrl)rjrkargsr r r!rlszChainMap.fromkeyscCs&|j|jdg|jddRS)zHNew ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]r rPN)r`rrdr(r r r!rdsz ChainMap.copycCs |dur i}|j|g|jRS)zyNew ChainMap with a new map followed by all previous maps. If no map is provided, an empty dict is used. Nr`r)r)rr r r! new_childszChainMap.new_childcCs|j|jddS)zNew ChainMap from maps[1:].rPNrr(r r r!parents szChainMap.parentscCs||jd|<dSNr )r)r)r0r@r r r!rCszChainMap.__setitem__cCs6z|jd|=Wn ty0td|Yn0dS)Nr $Key not found in the first mapping: )rrLr/r r r!rGs zChainMap.__delitem__cCs0z|jdWSty*tdYn0dS)zPRemove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.r z#No keys found in the first mapping.N)rrMrLr(r r r!rMs zChainMap.popitemcGs@z|jdj|g|RWSty:td|Yn0dS)zWRemove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].r r N)rrDrL)r)r0rr r r!rD!s z ChainMap.popcCs|jddS)z'Clear maps[0], leaving maps[1:] intact.r N)rrJr(r r r!rJ(szChainMap.clearcCs|jd||Sr )rrsrrr r r!rt,szChainMap.__ior__cCs,t|tjstS|}|jd||Sr )rmrrrvrdrrs)r)r<rr r r!ry0s  zChainMap.__or__cCs<t|tjstSt|}t|jD]}||q"||Sr$) rmrrrvrKr&rrsr`)r)r<rchildr r r!rz7s   zChainMap.__ror__)N)N)rr,r-r{r?rrrrrIrrrrbrrlrd__copy__r rr rCrGrMrDrJrtryrzr r r r!rs4      rc@seZdZdddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZedddZdS) rNcKs*i|_|dur|||r&||dSr$)datars)r)rKkwargsr r r!r?Gs  zUserDict.__init__cCs t|jSr$rSrr(r r r!rNszUserDict.__len__cCs:||jvr|j|St|jdr.|j||St|dS)Nr)rhasattrr`rrLr/r r r!rQs    zUserDict.__getitem__cCs||j|<dSr$r)r)r0itemr r r!rCXszUserDict.__setitem__cCs |j|=dSr$rr/r r r!rG[szUserDict.__delitem__cCs t|jSr$)rerr(r r r!rI^szUserDict.__iter__cCs ||jvSr$rr/r r r!rbszUserDict.__contains__cCs t|jSr$rrr(r r r!rbfszUserDict.__repr__cCs:t|tr||j|jBSt|tr6||j|BStSr$rmrr`rrKrvrrr r r!ryis   zUserDict.__or__cCs:t|tr||j|jBSt|tr6|||jBStSr$rrrr r r!rzps   zUserDict.__ror__cCs.t|tr|j|jO_n|j|O_|Sr$)rmrrrrr r r!rtws zUserDict.__ior__cCs4|j|j}|j|j|jd|jd<|SNr)r`rrTrsrdr)instr r r!r~szUserDict.__copy__cCsX|jturt|jSddl}|j}zi|_||}W||_n||_0|||Sr )r`rrrdrs)r)rdrrr r r!rds   z UserDict.copycCs|}|D] }|||<q |Sr$r )rjrkr@rr0r r r!rls zUserDict.fromkeys)N)N)rr,r-r?rrrCrGrIrrbryrzrtrrdrrlr r r r!rDs  rc@seZdZdZd@ddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$ZeZd%d&Zd'd(Zd)d*Zd+d,ZdAd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Z dd?Z"dS)BrzAA more or less complete user-defined wrapper around list objects.NcCsbg|_|dur^t|t|jkr0||jdd<n.t|trT|jdd|jdd<n t||_dSr$)rrrmrra)r)initlistr r r!r?s zUserList.__init__cCs t|jSr$rr(r r r!rbszUserList.__repr__cCs|j||kSr$r_UserList__castrrr r r!rszUserList.__lt__cCs|j||kSr$rrrr r r!rszUserList.__le__cCs|j||kSr$rrrr r r!rnszUserList.__eq__cCs|j||kSr$rrrr r r!rszUserList.__gt__cCs|j||kSr$rrrr r r!rszUserList.__ge__cCst|tr|jS|Sr$)rmrrrrr r r!__castszUserList.__castcCs ||jvSr$rr)rr r r!rszUserList.__contains__cCs t|jSr$rr(r r r!rszUserList.__len__cCs$t|tr||j|S|j|Sr$)rmslicer`rr)ir r r!rs zUserList.__getitem__cCs||j|<dSr$rr)r!rr r r!rCszUserList.__setitem__cCs |j|=dSr$rr r r r!rGszUserList.__delitem__cCsPt|tr||j|jSt|t|jr<||j|S||jt|Sr$rmrr`rrrarrr r r!rs  zUserList.__add__cCsPt|tr||j|jSt|t|jr<|||jS|t||jSr$r#rrr r r!__radd__s  zUserList.__radd__cCsRt|tr|j|j7_n2t|t|jr<|j|7_n|jt|7_|Sr$)rmrrrrarrr r r!rs  zUserList.__iadd__cCs||j|Sr$r`rr)rUr r r!__mul__szUserList.__mul__cCs|j|9_|Sr$rr&r r r!__imul__szUserList.__imul__cCs8|j|j}|j|j|jddd|jd<|Sr)r`rrTrsrr r r!rszUserList.__copy__cCs|j|dSr$)rappendrr r r!r)szUserList.appendcCs|j||dSr$)rinsertr"r r r!r*szUserList.insertcCs |j|Sr$)rrDr r r r!rDsz UserList.popcCs|j|dSr$)rremoverr r r!r,szUserList.removecCs|jdSr$)rrJr(r r r!rJszUserList.clearcCs ||Sr$rir(r r r!rd sz UserList.copycCs |j|Sr$)rrrr r r!r szUserList.countcGs|jj|g|RSr$rr)r)rrr r r!rszUserList.indexcCs|jdSr$)rrr(r r r!rszUserList.reversecOs|jj|i|dSr$)rsortr)rr=r r r!r.sz UserList.sortcCs*t|tr|j|jn |j|dSr$)rmrrextendrrr r r!r0s zUserList.extend)N)r+)#rr,r-r{r?rbrrrnrrrrrrrCrGrr$rr'__rmul__r(rr)r*rDr,rJrdrrrr.r0r r r r!rs@   rc@sxeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&ZeZd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1ejfd2d3Zd4d5Zd6d7Z dd:d;Z!d1ejfddudvZ?ddwdxZ@ddydzZAdd{d|ZBdd~dZCd1ejfddZDdddZEddZFddZGddZHddZIddZJdgS)rcCs<t|tr||_n&t|tr.|jdd|_n t||_dSr$)rmrrrr)seqr r r!r?%s   zUserString.__init__cCs t|jSr$)rrr(r r r!__str__-szUserString.__str__cCs t|jSr$rr(r r r!rb0szUserString.__repr__cCs t|jSr$)intrr(r r r!__int__3szUserString.__int__cCs t|jSr$)floatrr(r r r! __float__6szUserString.__float__cCs t|jSr$)complexrr(r r r! __complex__9szUserString.__complex__cCs t|jSr$)hashrr(r r r!__hash__<szUserString.__hash__cCs|jddfSr$rr(r r r!r?szUserString.__getnewargs__cCs t|tr|j|jkS|j|kSr$rmrrr)stringr r r!rnBs  zUserString.__eq__cCs t|tr|j|jkS|j|kSr$r=r>r r r!rGs  zUserString.__lt__cCs t|tr|j|jkS|j|kSr$r=r>r r r!rLs  zUserString.__le__cCs t|tr|j|jkS|j|kSr$r=r>r r r!rQs  zUserString.__gt__cCs t|tr|j|jkS|j|kSr$r=r>r r r!rVs  zUserString.__ge__cCst|tr|j}||jvSr$r=)r)charr r r!r[s zUserString.__contains__cCs t|jSr$rr(r r r!r`szUserString.__len__cCs||j|Sr$r%)r)rr r r!rcszUserString.__getitem__cCsJt|tr||j|jSt|tr6||j|S||jt|Sr$)rmrr`rrrrr r r!rfs   zUserString.__add__cCs.t|tr|||jS|t||jSr$)rmrr`rrrr r r!r$ms zUserString.__radd__cCs||j|Sr$r%r&r r r!r'rszUserString.__mul__cCs||j|Sr$r%r)rr r r!__mod__wszUserString.__mod__cCs|t||Sr$)r`r)r)templater r r!__rmod__zszUserString.__rmod__cCs||jSr$)r`r capitalizer(r r r!rE~szUserString.capitalizecCs||jSr$)r`rcasefoldr(r r r!rFszUserString.casefoldcGs||jj|g|RSr$)r`rcenterr)widthrr r r!rGszUserString.centerr cCs t|tr|j}|j|||Sr$)rmrrrr)substartendr r r!rs zUserString.countcCs"t|tr|j}||j|Sr$)rmrrr` removeprefix)r)prefixr r r!rNs zUserString.removeprefixcCs"t|tr|j}||j|Sr$)rmrrr` removesuffix)r)suffixr r r!rPs zUserString.removesuffixutf-8strictcCs.|dur dn|}|durdn|}|j||S)NrRrS)rencode)r)encodingerrorsr r r!rTszUserString.encodecCs|j|||Sr$)rendswith)r)rQrLrMr r r!rWszUserString.endswithcCs||j|Sr$)r`r expandtabs)r)tabsizer r r!rYszUserString.expandtabscCs t|tr|j}|j|||Sr$)rmrrfindrJr r r!r[s zUserString.findcOs|jj|i|Sr$)rformatr/r r r!r\szUserString.formatcCs |j|Sr$)r format_map)r)rr r r!r]szUserString.format_mapcCs|j|||Sr$r-rJr r r!rszUserString.indexcCs |jSr$)risalphar(r r r!r^szUserString.isalphacCs |jSr$)risalnumr(r r r!r_szUserString.isalnumcCs |jSr$)risasciir(r r r!r`szUserString.isasciicCs |jSr$)r isdecimalr(r r r!raszUserString.isdecimalcCs |jSr$)risdigitr(r r r!rbszUserString.isdigitcCs |jSr$)rrr(r r r!rszUserString.isidentifiercCs |jSr$)rislowerr(r r r!rcszUserString.islowercCs |jSr$)r isnumericr(r r r!rdszUserString.isnumericcCs |jSr$)r isprintabler(r r r!reszUserString.isprintablecCs |jSr$)risspacer(r r r!rfszUserString.isspacecCs |jSr$)ristitler(r r r!rgszUserString.istitlecCs |jSr$)risupperr(r r r!rhszUserString.isuppercCs |j|Sr$)rrr2r r r!rszUserString.joincGs||jj|g|RSr$)r`rljustrHr r r!riszUserString.ljustcCs||jSr$)r`rlowerr(r r r!rjszUserString.lowerNcCs||j|Sr$)r`rlstripr)charsr r r!rkszUserString.lstripcCs |j|Sr$)r partitionr)sepr r r!rnszUserString.partitionr+cCs6t|tr|j}t|tr |j}||j|||Sr$)rmrrr`r)r)oldrxmaxsplitr r r!rs   zUserString.replacecCs t|tr|j}|j|||Sr$)rmrrrfindrJr r r!rss zUserString.rfindcCs|j|||Sr$)rrindexrJr r r!rtszUserString.rindexcGs||jj|g|RSr$)r`rrjustrHr r r!ruszUserString.rjustcCs |j|Sr$)r rpartitionror r r!rvszUserString.rpartitioncCs||j|Sr$)r`rrstriprlr r r!rwszUserString.rstripcCs|j||Sr$)rrr)rprrr r r!rszUserString.splitcCs|j||Sr$)rrsplitrxr r r!ryszUserString.rsplitFcCs |j|Sr$)r splitlines)r)keependsr r r!rzszUserString.splitlinescCs|j|||Sr$)rr)r)rOrLrMr r r!rszUserString.startswithcCs||j|Sr$)r`rstriprlr r r!r|szUserString.stripcCs||jSr$)r`rswapcaser(r r r!r} szUserString.swapcasecCs||jSr$)r`rtitler(r r r!r~szUserString.titlecGs||jj|Sr$)r`r translaterAr r r!rszUserString.translatecCs||jSr$)r`rupperr(r r r!rszUserString.uppercCs||j|Sr$)r`rzfill)r)rIr r r!rszUserString.zfill)rRrS)rX)N)r+)N)Nr+)Nr+)F)N)Krr,r-r?r4rbr6r8r:r<rrnrrrrrrrrr$r'r1rBrDrErFrGrQmaxsizerrNrPrTrWrYr[r\r]rr^r_r`rarbrrcrdrerfrgrhrrirjrkr maketransrnrrsrtrurvrwrryrzrr|r}r~rrrr r r r!r#s         r)5r{rrsysrQ itertoolsr rr rr rkeywordrroperatorrrqrrreprlibrr_weakrefrr9 _collectionsr ImportErrorMutableSequenceregisterrr"KeysViewr# ItemsViewr. ValuesViewr1r~r2rKrrr rrr|rrrSequencerr r r r!sh            k/5Z