o ?Og@sdZgdZddlZddlZddlmZddlmZ ddlm Z ddl m ZddlmZdd lmZdd lmZdd lmZzdd lmZWn eyOYnwejezdd lmZWn eygYnwGdddej Z!Gdddej"Z#Gdddej$Z%Gddde&Z'Gddde(Z)zddlm)Z)Wn eyYnwzddlm*Z*Wn eyddZ*YnwddddddZ+d d!Z,zdd"lm,Z,Wn eyYnwGd#d$d$e(Z-Gd%d&d&ej.Z/Gd'd(d(ej.Z0Gd)d*d*ejZ1Gd+d,d,ej2Z3dS)-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)rc@eZdZddZdS)_OrderedDictKeysViewccst|jEdHdSNreversed_mappingselfr;/opt/alt/python310/lib64/python3.10/collections/__init__.py __reversed__<sz!_OrderedDictKeysView.__reversed__N__name__ __module__ __qualname__rrrrrr: rc@r)_OrderedDictItemsViewccs&t|jD] }||j|fVqdSrrrkeyrrrrAsz"_OrderedDictItemsView.__reversed__Nrrrrrr#?r"r#c@r)_OrderedDictValuesViewccs"t|jD]}|j|VqdSrrr$rrrrGsz#_OrderedDictValuesView.__reversed__Nrrrrrr&Er"r&c@seZdZdZdS)_Link)prevnextr% __weakref__N)rr r! __slots__rrrrr'Ksr'c@seZdZdZd1ddZejeefddZej fddZ d d Z d d Z d dZ d2ddZ d2ddZddZejjZZddZddZddZejjZeZefddZd3dd Zed!d"Zd#d$Zd%d&Ze d3d'd(Z!d)d*Z"d+d,Z#d-d.Z$d/d0Z%dS)4rz)Dictionary that remembers insertion orderrcKs^z|jWnty#t|_t|j|_}||_|_i|_Ynw|j|fi|dS)zInitialize an ordered dictionary. The signature is the same as regular dictionaries. Keyword argument order is preserved. N) _OrderedDict__rootAttributeErrorr'_OrderedDict__hardroot_proxyr(r)_OrderedDict__map_OrderedDict__update)rotherkwdsrootrrr__init__]s    zOrderedDict.__init__c CsZ||vr%||j|<}|j}|j}||||_|_|_||_|||_||||dS)z!od.__setitem__(i, y) <==> od[i]=yN)r0r,r(r)r%) rr%valueZ dict_setitemrZLinklinkr4lastrrr __setitem__js zOrderedDict.__setitem__cCs>||||j|}|j}|j}||_||_d|_d|_dS)z od.__delitem__(y) <==> del od[y]N)r0popr(r))rr%Z dict_delitemr7 link_prev link_nextrrr __delitem__xs   zOrderedDict.__delitem__cc4|j}|j}||ur|jV|j}||us dSdS)zod.__iter__() <==> iter(od)N)r,r)r%rr4Zcurrrrr__iter__zOrderedDict.__iter__ccr>)z#od.__reversed__() <==> reversed(od)N)r,r(r%r?rrrrrAzOrderedDict.__reversed__cCs*|j}||_|_|jt|dS)z.od.clear() -> None. Remove all items from od.N)r,r(r)r0cleardict)rr4rrrrBs  zOrderedDict.clearTcCsj|std|j}|r|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)KeyErrorr,r(r)r%r0rCr:)rr8r4r7r;r<r%r6rrrpopitems  zOrderedDict.popitemc Csv|j|}|j}|j}|j}||_||_|j}|r*|j}||_||_||_||_dS|j}||_||_||_||_dS)zMove an existing element to the end (or beginning if last is false). Raise KeyError if the element does not exist. N)r0r(r)r,) rr%r8r7r;r<Z soft_linkr4firstrrr move_to_ends$   zOrderedDict.move_to_endcCsVtj}t|d}||j}|||jd7}|||j|7}|||j|7}|S)N)_sys getsizeoflen__dict__r0r.r,)rZsizeofnsizerrr __sizeof__s  zOrderedDict.__sizeof__cCt|S)z:D.keys() -> a set-like object providing a view on D's keys)rrrrrkeyszOrderedDict.keyscCrQ)z a set-like object providing a view on D's items)r#rrrritemsrSzOrderedDict.itemscCrQ)z6D.values() -> an object providing a view on D's values)r&rrrrvaluesrSzOrderedDict.valuescCs0||vr ||}||=|S||jurt||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__markerrD)rr%defaultresultrrrr:s 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. rrr%rWrrr setdefaultszOrderedDict.setdefaultcCs*|s d|jjfSd|jjt|fS)zod.__repr__() <==> repr(od)z%s()z%s(%r)) __class__rlistrTrrrr__repr__szOrderedDict.__repr__cCsDt|}ttD]}||dq |jd|pddt|fS)z%Return state information for picklingNr)varscopyrr:r[iterrT)rZ inst_dictkrrr __reduce__s zOrderedDict.__reduce__cC ||S)z!od.copy() -> a shallow copy of odr[rrrrr_ zOrderedDict.copycC|}|D]}|||<q|S)zYCreate a new ordered dictionary with keys from iterable and values set to value. r)clsiterabler6rr%rrrfromkeyss zOrderedDict.fromkeyscCs2t|trt||ottt||St||S)zod.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive. ) isinstancerrC__eq__allmap_eqrr2rrrrks  zOrderedDict.__eq__cCs|||Sr)updaterorrr__ior__%s zOrderedDict.__ior__cCs&t|tstS||}|||SrrjrCNotImplementedr[rprr2newrrr__or__)   zOrderedDict.__or__cCs&t|tstS||}|||Srrrrtrrr__ror__0rwzOrderedDict.__ror__)r)Tr)&rr r!__doc__r5rCr9r/r'r=r@rrBrErGrP_collections_abcMutableMappingrpr1rRrTrU__ne__objectrVr:rZ_recursive_reprr]rbr_ classmethodrirkrqrvrxrrrrrNs<             r)r) _tuplegettercCstt||dS)N)doc)property _itemgetter)indexrrrrFsrF)renamedefaultsmodulec sttr ddttttt|}|rFt}t D]!\}}| r9t |s9| ds9||vr@d||<| |q$|gD]"}t|turWtd| sbtd|t |rmtd|qKt}D] }| dr|std|||vrtd|| |qsi}|d urt|}t|tkrtd tttttt|}tttjtd } d kr| d7} d d ddDdtjtttttf\id|d} d| d| d} t| | } d| _d|d | d| _|d ur|| _tfdd} d|d| j_fdd}d|d|_fd d!}fd"d#}fd$d%}| | j||||fD] }|d&|j|_qW|d | dd'|| | ||||d( }t D]\}}td)|}t||||<q|t|tf|}|d urz t d j!"d*d+}Wn t#tfyYnw|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, rH(css|]}|dVqdS)z=%rNr).0namerrr sznamedtuple..) namedtuple_) _tuple_new __builtins__rz lambda _cls, z: _tuple_new(_cls, (z))__new__zCreate new instance of cs2||}|krtddt||S)Nz Expected z arguments, got ) TypeErrorrL)rgrhrX)_len num_fields tuple_newrr_makes  znamedtuple.._makez Make a new z# object from a sequence or iterablecs.||j|}|rtdt||S)NzGot unexpected field names: )rr: ValueErrorr\)rr3rX)_map field_namesrr_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_fmtrrr]znamedtuple..__repr__cs|j|S)z9Return a new dict which maps field names to their values.)_fieldsr)_dict_ziprr_asdictrznamedtuple.._asdictcs|S)z7Return self as a plain tuple. Used by copy and pickle.rr)_tuplerr__getnewargs__rSz"namedtuple..__getnewargs__.r) ryr+r_field_defaultsrrrr]rr__match_args__zAlias for field number r__main__)%rjstrreplacesplitr\rmrJinternset enumerate isidentifier _iskeyword startswithaddtyperrtuplerLrCrzipjoinrevalrry __defaults__r__func__r!r _getframe f_globalsgetr-r )typenamerrrrseenrrfield_defaultsarg_list namespacecoderrrr]rrmethodclass_namespacerrXr) rrrrrrrrrrr Hs             r cCs&|j}|D] }||dd||<qdS)z!Tally elements from the iterable.r rHN)r)mappingrhZ mapping_getelemrrr_count_elementssr)rcseZdZdZd=fdd ZddZddZd=d d Zd d Ze d=d dZ d=fdd Z d=ddZ ddZ ddZfddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Z d;d<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)superr5rp)rrhr3rdrrr55s zCounter.__init__cCsdS)z1The count of elements not in the Counter is zero.r rr$rrr __missing__CszCounter.__missing__cCs t|S)zSum of the counts)sumrUrrrrtotalHs z Counter.totalcCs>|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)] NrHT)r%reverser r%)sortedrTrheapqnlargest)rrNrrrr most_commonLs 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_repeatrTrrrrelements\szCounter.elementscCstd)Nz@Counter.fromkeys() is undefined. Use Counter(iterable) instead.)NotImplementedError)rgrhvrrrrits zCounter.fromkeysc sr|dur.t|tjr)|r"|j}|D] \}}|||d||<qn t|nt|||r7||dSdS)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 )rjrzMappingrrTrrprrrhr3self_getrcountrdrrrps  zCounter.updatecKsr|dur.|j}t|tjr |D] \}}||d|||<qn|D] }||dd||<q"|r7||dSdS)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 rH)rrjrzrrTsubtractrrrrrs zCounter.subtractcCrc)zReturn a shallow copy.rdrrrrr_rez Counter.copycCs|jt|ffSr)r[rCrrrrrbzCounter.__reduce__cs||vr t|dSdS)zGLike dict.__delitem__() but does not raise KeyError for missing values.N)rr=)rrrdrrr=szCounter.__delitem__c*ttstStfddfDS)z=True if all counts agree. Missing counts are treated as zero.c3s*|]}|D] }||kVqqdSrrrcer2rrrr(z!Counter.__eq__..rjrrsrlrorrrrk zCounter.__eq__cCst|tstS||k S)z@True if any counts disagree. Missing counts are treated as zero.rjrrsrorrrr|s  zCounter.__ne__cr)z:True if all counts in self are a subset of those in other.c3s*|]}|D] }||kVqqdSrrrrrrrrz!Counter.__le__..rrorrr__le__rzCounter.__le__cCst|tstS||ko||kS)zATrue if all counts in self are a proper subset of those in other.rrorrr__lt__ zCounter.__lt__cr)z.rrorrr__ge__rzCounter.__ge__cCst|tstS||ko||kS)zCTrue if all counts in self are a proper superset of those in other.rrorrr__gt__rzCounter.__gt__cCsR|s |jjdSzt|}Wn tyt|}Ynw|jjd|dS)Nz()rr)r[rrCrr)rdrrrr]s  zCounter.__repr__cCspt|tstSt}|D]\}}|||}|dkr |||<q|D]\}}||vr5|dkr5|||<q%|S)zAdd counts from two counters. >>> Counter('abbb') + Counter('bcc') Counter({'b': 4, 'c': 2, 'a': 1}) r rjrrsrTrr2rXrrnewcountrrr__add__s  zCounter.__add__cCstt|tstSt}|D]\}}|||}|dkr |||<q|D]\}}||vr7|dkr7d|||<q%|S)z Subtract count, but keep only results with positive counts. >>> Counter('abbbc') - Counter('bccd') Counter({'b': 2, 'a': 1}) r rrrrr__sub__-s   zCounter.__sub__cCs|t|tstSt}|D]\}}||}||kr|n|}|dkr&|||<q|D]\}}||vr;|dkr;|||<q+|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 rrr2rXrr other_countrrrrrv@s zCounter.__or__cCsRt|tstSt}|D]\}}||}||kr|n|}|dkr&|||<q|S)z Intersection is the minimum of corresponding counts. >>> Counter('abbb') & Counter('bcc') Counter({'b': 1}) r rrrrr__and__Ts zCounter.__and__cCs,t}|D] \}}|dkr|||<q|S)zEAdds an empty counter, effectively stripping negative and zero countsr rrTrrXrrrrr__pos__es 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 rrrrr__neg__ms  zCounter.__neg__cCs&dd|D}|D]}||=q |S)z?Internal method to strip elements with a negative or zero countcSsg|] \}}|dks|qS)r r)rrrrrr zsz*Counter._keep_positive..)rT)r nonpositiverrrr_keep_positivexszCounter._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}) rTrrr2rrrrr__iadd__ 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}) rrrrr__isub__rzCounter.__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)rr2rrrrrrrq  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)rr2rrrrrr__iand__rzCounter.__iand__r)#rr r!ryr5rrrrrrirprr_rbr=rkr|rrrrr]rrrvrrrrrrrqr __classcell__rrrdrrs@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|pig|_dS)zInitialize a ChainMap by setting *maps* to the given mappings. If no mappings are provided, a single empty dictionary is used. N)r\maps)rrrrrr5szChainMap.__init__cCst|r)rDr$rrrrszChainMap.__missing__c Cs6|jD]}z||WStyYqw||Sr)rrDr)rr%rrrr __getitem__s   zChainMap.__getitem__NcCs||vr||S|SrrrYrrrrz ChainMap.getcCsttj|jSr)rLrunionrrrrr__len__zChainMap.__len__cCs,i}t|jD] }|t|qt|Sr)rrrprCrir`)rrrrrrr@szChainMap.__iter__cstfdd|jDS)Nc3s|]}|vVqdSrr)rmrrrrsz(ChainMap.__contains__..anyrr$rrr __contains__szChainMap.__contains__cC t|jSrrrrrr__bool__ zChainMap.__bool__cCs"|jjddtt|jdS)Nrrr)r[rrrmreprrrrrrr]s"zChainMap.__repr__cGs|tj|g|RS)z?Create a ChainMap with a single dict created from the iterable.)rCri)rgrhargsrrrriszChainMap.fromkeyscCs&|j|jdg|jddRS)zHNew ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]r rHN)r[rr_rrrrr_s&z ChainMap.copycKs0|dur|}n|r|||j|g|jRS)zNew ChainMap with a new map followed by all previous maps. If no map is provided, an empty dict is used. Keyword arguments update the map or new empty dict. N)rpr[r)rr kwargsrrr new_childs  zChainMap.new_childcCs|j|jddS)zNew ChainMap from maps[1:].rHN)r[rrrrrparentsszChainMap.parentscCs||jd|<dSNr )r)rr%r6rrrr9 r zChainMap.__setitem__cCs0z |jd|=WdStytd|w)Nr $Key not found in the first mapping: )rrDr$rrrr=s  zChainMap.__delitem__cCs(z|jdWStytdw)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.)rrErDrrrrrEs  zChainMap.popitemcGs8z |jdj|g|RWStytd|w)zWRemove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].r r)rr:rD)rr%rrrrr:s  z ChainMap.popcCs|jddS)z'Clear maps[0], leaving maps[1:] intact.r N)rrBrrrrrB$szChainMap.clearcCs|jd||Sr)rrprorrrrq(szChainMap.__ior__cCs,t|tjstS|}|jd||Sr)rjrzrrsr_rrp)rr2r rrrrv,s zChainMap.__or__cCs<t|tjstSt|}t|jD]}||q||Sr) rjrzrrsrCrrrpr[)rr2r childrrrrx3s   zChainMap.__ror__r)rr r!ryr5rrrr r@rrr~r]rrir___copy__rrrr9r=rEr:rBrqrvrxrrrrrs6       rc@seZdZdddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZedddZdS)rNcKs.i|_|dur |||r||dSdSr)datarp)rrCrrrrr5Cs  zUserDict.__init__cCrrrLrrrrrr JrzUserDict.__len__cCs6||jvr |j|St|jdr|j||St|)Nr)rhasattrr[rrDr$rrrrMs   zUserDict.__getitem__cC||j|<dSrr)rr%itemrrrr9TzUserDict.__setitem__cC |j|=dSrr!r$rrrr=W zUserDict.__delitem__cCrr)r`rrrrrr@ZrzUserDict.__iter__cC ||jvSrr!r$rrrr^rzUserDict.__contains__cCrrrrrrrrr]brzUserDict.__repr__cCs:t|tr||j|jBSt|tr||j|BStSrrjrr[rrCrsrorrrrve  zUserDict.__or__cCs:t|tr||j|jBSt|tr|||jBStSrr(rorrrrxlr)zUserDict.__ror__cCs0t|tr|j|jO_|S|j|O_|Sr)rjrrrorrrrqss zUserDict.__ior__cCs4|j|j}|j|j|jd|jd<|SNr)r[rrMrpr_rinstrrrrzszUserDict.__copy__cCsX|jtur t|jSddl}|j}z i|_||}W||_n||_w|||Sr)r[rrr_rp)rr_rrrrrr_s   z UserDict.copycCrfrr)rgrhr6rr%rrrris zUserDict.fromkeysr)rr r!r5r rr9r=r@rr]rvrxrqrr_rrirrrrr@s   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.NcCsjg|_|dur3t|t|jkr||jdd<dSt|tr,|jdd|jdd<dSt||_dSdSr)rrrjrr\)rinitlistrrrr5s zUserList.__init__cCrrr'rrrrr]rzUserList.__repr__cCs|j||kSrr_UserList__castrorrrrrzUserList.__lt__cCs|j||kSrr.rorrrrrzUserList.__le__cCs|j||kSrr.rorrrrkrzUserList.__eq__cCs|j||kSrr.rorrrrrzUserList.__gt__cCs|j||kSrr.rorrrrrzUserList.__ge__cCst|tr|jS|Sr)rjrrrorrr__castr zUserList.__castcCr&rr!rr"rrrrrzUserList.__contains__cCrrrrrrrr rzUserList.__len__cCs$t|tr ||j|S|j|Sr)rjslicer[rrirrrrs  zUserList.__getitem__cCr rr!rr4r"rrrr9r#zUserList.__setitem__cCr$rr!r3rrrr=r%zUserList.__delitem__cCsPt|tr||j|jSt|t|jr||j|S||jt|Srrjrr[rrr\rorrrr zUserList.__add__cCsPt|tr||j|jSt|t|jr|||jS|t||jSrr6rorrr__radd__r7zUserList.__radd__cCsVt|tr|j|j7_|St|t|jr |j|7_|S|jt|7_|Sr)rjrrrr\rorrrrs zUserList.__iadd__cC||j|Srr[rrrNrrr__mul__rzUserList.__mul__cCs|j|9_|Srr!r;rrr__imul__szUserList.__imul__cCs8|j|j}|j|j|jddd|jd<|Sr*)r[rrMrpr+rrrrszUserList.__copy__cC|j|dSr)rappendr1rrrr?rzUserList.appendcCs|j||dSr)rinsertr5rrrr@r zUserList.insertcC |j|Sr)rr:r3rrrr:r%z UserList.popcCr>r)rremover1rrrrCrzUserList.removecC|jdSr)rrBrrrrrBr#zUserList.clearcCrcrrdrrrrr_rz UserList.copycCrBr)rrr1rrrrr%zUserList.countcGs|jj|g|RSrrr)rr"rrrrr r zUserList.indexcCrDr)rrrrrrrr#zUserList.reversecOs|jj|i|dSr)rsortrrr3rrrrFsz UserList.sortcCs,t|tr|j|jdS|j|dSr)rjrrextendrorrrrHs zUserList.extendrrA)#rr r!ryr5r]rrrkrrr/rr rr9r=rr8rr<__rmul__r=rr?r@r:rCrBr_rrrrFrHrrrrrsB     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 ||_dSt|tr|jdd|_dSt||_dSr)rjrrrrseqrrrr5!s   zUserString.__init__cCrr)rrrrrr__str__)rzUserString.__str__cCrrr'rrrrr],rzUserString.__repr__cCrr)intrrrrr__int__/rzUserString.__int__cCrr)floatrrrrr __float__2rzUserString.__float__cCrr)complexrrrrr __complex__5rzUserString.__complex__cCrr)hashrrrrr__hash__8rzUserString.__hash__cCs|jddfSrr!rrrrr;rzUserString.__getnewargs__cCs t|tr |j|jkS|j|kSrrjrrrstringrrrrk>   zUserString.__eq__cCs t|tr |j|jkS|j|kSrrVrWrrrrCrYzUserString.__lt__cCs t|tr |j|jkS|j|kSrrVrWrrrrHrYzUserString.__le__cCs t|tr |j|jkS|j|kSrrVrWrrrrMrYzUserString.__gt__cCs t|tr |j|jkS|j|kSrrVrWrrrrRrYzUserString.__ge__cCst|tr|j}||jvSrrV)rcharrrrrWs  zUserString.__contains__cCrrrrrrrr \rzUserString.__len__cCs||j|Srr:)rrrrrr_rzUserString.__getitem__cCsJt|tr||j|jSt|tr||j|S||jt|Sr)rjrr[rrrorrrrbs  zUserString.__add__cCs.t|tr |||jS|t||jSr)rjrr[rrorrrr8is zUserString.__radd__cCr9rr:r;rrrr<nrzUserString.__mul__cCs||j|Srr:rrrrr__mod__srzUserString.__mod__cCs|t||Sr)r[r)rtemplaterrr__rmod__vr zUserString.__rmod__cC||jSr)r[r capitalizerrrrr`zrzUserString.capitalizecCr_r)r[rcasefoldrrrrra}rzUserString.casefoldcG||jj|g|RSr)r[rcenterrwidthrrrrrczUserString.centerr cC t|tr|j}|j|||Sr)rjrrrrsubstartendrrrr zUserString.countcC"t|tr|j}||j|Sr)rjrrr[ removeprefix)rprefixrrrrn zUserString.removeprefixcCrmr)rjrrr[ removesuffix)rsuffixrrrrqrpzUserString.removesuffixutf-8strictcCs.|durdn|}|durdn|}|j||S)Nrsrt)rencode)rencodingerrorsrrrruszUserString.encodecC|j|||Sr)rendswith)rrrrjrkrrrryrzUserString.endswithcC||j|Sr)r[r expandtabs)rtabsizerrrr|r zUserString.expandtabscCrgr)rjrrfindrhrrrr~rlzUserString.findcOs|jj|i|Sr)rformatrGrrrrr zUserString.formatcCrBr)r format_map)rrrrrrr%zUserString.format_mapcCrxrrErhrrrrrzUserString.indexcC |jSr)risalpharrrrrrzUserString.isalphacCrr)risalnumrrrrrrzUserString.isalnumcCrr)risasciirrrrrrzUserString.isasciicCrr)r isdecimalrrrrrrzUserString.isdecimalcCrr)risdigitrrrrrrzUserString.isdigitcCrr)rrrrrrrrzUserString.isidentifiercCrr)rislowerrrrrrrzUserString.islowercCrr)r isnumericrrrrrrzUserString.isnumericcCrr)r isprintablerrrrrrzUserString.isprintablecCrr)risspacerrrrrrzUserString.isspacecCrr)ristitlerrrrrrzUserString.istitlecCrr)risupperrrrrrrzUserString.isuppercCrBr)rrrKrrrrr%zUserString.joincGrbr)r[rljustrdrrrrrfzUserString.ljustcCr_r)r[rlowerrrrrrrzUserString.lowerNcCr{r)r[rlstriprcharsrrrrr zUserString.lstripcCrBr)r partitionrseprrrrr%zUserString.partitionrAcCs6t|tr|j}t|tr|j}||j|||Sr)rjrrr[r)roldrumaxsplitrrrrs  zUserString.replacecCrgr)rjrrrfindrhrrrrrlzUserString.rfindcCrxr)rrindexrhrrrrrzUserString.rindexcGrbr)r[rrjustrdrrrrrfzUserString.rjustcCrBr)r rpartitionrrrrrr%zUserString.rpartitioncCr{r)r[rrstriprrrrrr zUserString.rstripcC|j||Sr)rrrrrrrrrr#zUserString.splitcCrr)rrsplitrrrrrr#zUserString.rsplitFcCrBr)r splitlines)rkeependsrrrrr%zUserString.splitlinescCrxr)rr)rrorjrkrrrrrzUserString.startswithcCr{r)r[rstriprrrrrr zUserString.stripcCr_r)r[rswapcaserrrrrrzUserString.swapcasecCr_r)r[rtitlerrrrr rzUserString.titlecGs||jj|Sr)r[r translater[rrrr r zUserString.translatecCr_r)r[rupperrrrrrrzUserString.uppercCr{r)r[rzfill)rrerrrrr zUserString.zfill)rsrt)rzrrI)NrA)F)Krr r!r5rMr]rOrQrSrUrrkrrrrrr rrr8r<rJr\r^r`rarcrJmaxsizerrnrqruryr|r~rrrrrrrrrrrrrrrrrrrr maketransrrrrrrrrrrrrrrrrrrrrrrs          r)4ry__all__rzsysrJ itertoolsr rr rr rkeywordrroperatorrrnrrreprlibrr~_weakrefrr/ _collectionsr ImportErrorMutableSequenceregisterrKeysViewr ItemsViewr# ValuesViewr&r}r'rCrrr rrr{rrrSequencerrrrrsr            k    0 =Z