f _c@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)Z stacklevelzmodule z has no attribute ) _collections_abc__all__ZgetattrwarningsZwarnZDeprecationWarningZglobalsAttributeError__name__)nameZobjrr-/usr/lib64/python3.10/collections/__init__.py __getattr__6s   rc@eZdZddZdS)_OrderedDictKeysViewccst|jEdHdSNreversedZ_mappingselfrrr __reversed__Lz!_OrderedDictKeysView.__reversed__Nr __module__ __qualname__r#rrrrrJrc@r)_OrderedDictItemsViewccs$t|jD]}||j|fVq dSrrr"keyrrrr#Qz"_OrderedDictItemsView.__reversed__Nr%rrrrr)Or(r)c@r)_OrderedDictValuesViewccs t|jD]}|j|Vq dSrrr*rrrr#Wr,z#_OrderedDictValuesView.__reversed__Nr%rrrrr-Ur(r-c@seZdZdZdS)_Link)prevnextr+Z __weakref__N)rr&r' __slots__rrrrr.[sr.c@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 orderrcKs^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__rootrr._OrderedDict__hardroot_proxyr/r0_OrderedDict__map_OrderedDict__update)r"otherkwdsrootrrr__init__ms    zOrderedDict.__init__c CsZ||vrJ||j|<}|j}|j}||||_|_|_||_|||_||||dS)z!od.__setitem__(i, y) <==> od[i]=yN)r5r2r/r0r+) r"r+valueZ dict_setitemrZLinklinkr9lastrrr __setitem__zs zOrderedDict.__setitem__cCs>||||j|}|j}|j}||_||_d|_d|_dS)z od.__delitem__(y) <==> del od[y]N)r5popr/r0)r"r+Z dict_delitemr< link_prev link_nextrrr __delitem__s  zOrderedDict.__delitem__cc(|j}|j}||ur$|jV|j}q dS)zod.__iter__() <==> iter(od)N)r2r0r+r"r9Zcurrrrr__iter__ zOrderedDict.__iter__ccrC)z#od.__reversed__() <==> reversed(od)N)r2r/r+rDrrrr#rFzOrderedDict.__reversed__cCs*|j}||_|_|jt|dS)z.od.clear() -> None. Remove all items from od.N)r2r/r0r5cleardict)r"r9rrrrGs  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)KeyErrorr2r/r0r+r5rHr?)r"r=r9r<r@rAr+r;rrrpopitems  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)r5r/r0r2) r"r+r=r<r@rAZ soft_linkr9Zfirstrrr move_to_ends$ zOrderedDict.move_to_endcCsVtj}t|d}||j}|||jd7}|||j|7}|||j|7}|S)Nr)_sysZ getsizeoflen__dict__r5r3r2)r"ZsizeofnZsizerrr __sizeof__s  zOrderedDict.__sizeof__cCt|S)z:D.keys() -> a set-like object providing a view on D's keys)rr!rrrkeyszOrderedDict.keyscCrR)z a set-like object providing a view on D's items)r)r!rrritemsrTzOrderedDict.itemscCrR)z6D.values() -> an object providing a view on D's values)r-r!rrrvaluesrTzOrderedDict.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__markerrI)r"r+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. rr"r+rXrrr setdefaultszOrderedDict.setdefaultcCs*|sd|jjfSd|jjt|fS)zod.__repr__() <==> repr(od)z%s()z%s(%r)) __class__rlistrUr!rrr__repr__szOrderedDict.__repr__cCsDt|}ttD]}||dq|jd|p4ddt|fS)z%Return state information for picklingNr)Zvarscopyrr?r\iterrU)r"Z inst_dictZkrrr __reduce__s zOrderedDict.__reduce__cC ||S)z!od.copy() -> a shallow copy of odr\r!rrrr_rTzOrderedDict.copycC|}|D] }|||<q |S)zYCreate a new ordered dictionary with keys from iterable and values set to value. r)clsiterabler;r"r+rrrfromkeys#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. ) isinstancerrH__eq__allmap_eqr"r7rrrri,s zOrderedDict.__eq__cCs|||Sr)updatermrrr__ior__5s zOrderedDict.__ior__cCs&t|tstS||}|||SrrhrHNotImplementedr\rnr"r7newrrr__or__9    zOrderedDict.__or__cCs&t|tstS||}|||Srrprrrrr__ror__@ruzOrderedDict.__ror__)rTrwrr)&rr&r'__doc__r:rHr>r4r.rBrEr#rGrJrKrQrMutableMappingrnr6rSrUrV__ne__objectrWr?r[_recursive_reprr^rar_ classmethodrgrirortrvrrrrr^s:             r)r) _tuplegettercCstt||dS)N)doc)property _itemgetter)indexrrrrVrF)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,z Z_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, rL(css|]}|dVqdS)z=%rNr).0rrrr rznamedtuple..)Z namedtuple_)Z _tuple_newZ __builtins__rz lambda _cls, z: _tuple_new(_cls, (z))__new__zCreate new instance of cs2||}|kr.tddt||S)Nz Expected z arguments, got ) TypeErrorrN)rerfrY)_len num_fields tuple_newrr_makes  znamedtuple.._makez Make a new z# object from a sequence or iterablecs.||j|}|r*tdt||S)NzGot unexpected field names: )rr? ValueErrorr])r"r8rY)_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^rTznamedtuple..__repr__cs|j|S)z9Return a new dict which maps field names to their values.)_fieldsr!)_dict_ziprr_asdictrTznamedtuple.._asdictcs|S)z7Return self as a plain tuple. Used by copy and pickle.rr!)_tuplerr__getnewargs__rTz"namedtuple..__getnewargs__Z.r) rxr1rZ_field_defaultsrrrr^rrzAlias for field number rZ__main__)%rhstrreplacesplitr]rkrMZinternsetZ enumerate isidentifier _iskeyword startswithZaddtyperrZtuplerNrHr ZzipjoinrZevalrrxZ __defaults__r}Z__func__r'r~Z _getframeZ f_globalsgetrr&)ZtypenamerrrrZseenrrZfield_defaultsZarg_listZ namespaceZcoderrrr^rrZmethodZclass_namespacerrYr) rrrrrrrrrrrXs                 rcCs&|j}|D]}||dd||<q dS)z!Tally elements from the iterable.r rLN)r)mappingrfZ mapping_getelemrrr_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:rn)r"rfr8rcrrr:Ds zCounter.__init__cCsdS)z1The count of elements not in the Counter is zero.r rr*rrr __missing__RzCounter.__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)] NrLT)r+reverser r+)ZsortedrUrheapqZnlargest)r"rPrrrr 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. )_chainZ from_iterable_starmap_repeatrUr!rrrelementsgszCounter.elementscCs tddS)Nz@Counter.fromkeys() is undefined. Use Counter(iterable) instead.)ZNotImplementedError)rerfZvrrrrgs 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 )rhrMappingrrUrrnrr"rfr8Zself_getrcountrcrrrns  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 rL)rrhrrrUsubtractrrrrrs zCounter.subtractcCrb)zReturn a shallow copy.rcr!rrrr_rTz Counter.copycCs|jt|ffSr)r\rHr!rrrrar$zCounter.__reduce__cs||vrt|dS)zGLike dict.__delitem__() but does not raise KeyError for missing values.N)rrB)r"rrcrrrBszCounter.__delitem__c*ttstStfddfDS)z=True if all counts agree. Missing counts are treated as zero.c3s(|] }|D]}||kVq qdSrrrcZer7r"rrrrz!Counter.__eq__..rhrrqrjrmrrrri zCounter.__eq__cCst|tstS||k S)z@True if any counts disagree. Missing counts are treated as zero.rhrrqrmrrrrzrzCounter.__ne__cr)z:True if all counts in self are a subset of those in other.c3s(|] }|D]}||kVq qdSrrrrrrrrz!Counter.__le__..rrmrrr__le__rzCounter.__le__cCst|tstS||ko||kS)zATrue if all counts in self are a proper subset of those in other.rrmrrr__lt__rzCounter.__lt__cr)z.rrmrrr__ge__rzCounter.__ge__cCst|tstS||ko||kS)zCTrue if all counts in self are a proper superset of those in other.rrmrrr__gt__rzCounter.__gt__cCsR|s|jjdSzt|}Wnty<t|}Yn0|jjd|dS)Nz()rr)r\rrHrr)r"drrrr^s 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 rhrrqrUr"r7rYrrnewcountrrr__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 rrrrr__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"r7rYrr other_countrrrrrtGs   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 rrrrr__and__[s  zCounter.__and__cCs,t}|D]\}}|dkr|||<q|S)zEAdds an empty counter, effectively stripping negative and zero countsr rrUr"rYrrrrr__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 rrrrr__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)rrrrrrZ rz*Counter._keep_positive..)rU)r"Z nonpositiverrrr_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}) rUrr"r7rrrrr__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)r"r7rrrrrrro  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"r7rrrrrr__iand__rzCounter.__iand__rrrrr)"rr&r'rxr:rrrr}rgrnrr_rarBrirzrrrrr^rrrtrrrrrrrorZ __classcell__rrrcrrs<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)r]maps)r"rrrrr:szChainMap.__init__cCs t|dSr)rIr*rrrrr$zChainMap.__missing__c Cs6|jD]$}z||WSty*Yq0||Sr)rrIr)r"r+rrrr __getitem__s   zChainMap.__getitem__NcCs||vr||S|SrrrZrrrrr$z ChainMap.getcCsttj|jSr)rNrZunionrr!rrr__len__r$zChainMap.__len__cCs&i}t|jD]}||qt|Sr)r rrnr`)r"rrrrrrEs zChainMap.__iter__cstfdd|jDS)Nc3s|]}|vVqdSrr)rmrrrrrz(ChainMap.__contains__..Zanyrr*rrr __contains__r$zChainMap.__contains__cC t|jSrrr!rrr__bool__r$zChainMap.__bool__cCs"|jjddtt|jdS)Nrrr)r\rrrkreprrr!rrrr^rTzChainMap.__repr__cGs|tj|g|RS)z?Create a ChainMap with a single dict created from the iterable.)rHrg)rerfargsrrrrgrzChainMap.fromkeyscCs&|j|jdg|jddRS)zHNew ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]r rLN)r\rr_r!rrrr_rTz 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"rrrr new_childszChainMap.new_childcCs|j|jddS)zNew ChainMap from maps[1:].rLNrr!rrrparents rzChainMap.parentscCs||jd|<dSNr )r)r"r+r;rrrr>r$zChainMap.__setitem__cCs6z|jd|=Wn ty0td|Yn0dS)Nr $Key not found in the first mapping: )rrIr*rrrrBs 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)rrJrIr!rrrrJs 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 rN)rr?rI)r"r+rrrrr?!s z ChainMap.popcCs|jddS)z'Clear maps[0], leaving maps[1:] intact.r N)rrGr!rrrrG(rTzChainMap.clearcCs|jd||Sr)rrnrmrrrro,szChainMap.__ior__cCs,t|tjstS|}|jd||Sr)rhrrrqr_rrn)r"r7rrrrrt0s  zChainMap.__or__cCs<t|tjstSt|}t|jD]}||q"||Sr) rhrrrqrHr rrnr\)r"r7rZchildrrrrv7s   zChainMap.__ror__rr)rr&r'rxr:rrrrrErrr|r^r}rgr___copy__rrrr>rBrJr?rGrortrvrrrrrs4      rc@seZdZdddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZedddZdS) rNcKs*i|_|dur|||r&||dSr)datarn)r"rHZkwargsrrrr:Gs  zUserDict.__init__cCrrrNrr!rrrrNr$zUserDict.__len__cCs:||jvr|j|St|jdr.|j||St|dS)Nr)rZhasattrr\rrIr*rrrrQs    zUserDict.__getitem__cC||j|<dSrr)r"r+itemrrrr>Xr$zUserDict.__setitem__cC |j|=dSrrr*rrrrB[r$zUserDict.__delitem__cCrr)r`rr!rrrrE^r$zUserDict.__iter__cC ||jvSrrr*rrrrbr$zUserDict.__contains__cCrrrrr!rrrr^fr$zUserDict.__repr__cCs:t|tr||j|jBSt|tr6||j|BStSrrhrr\rrHrqrmrrrrti   zUserDict.__or__cCs:t|tr||j|jBSt|tr6|||jBStSrrrmrrrrvprzUserDict.__ror__cCs.t|tr|j|jO_n|j|O_|Sr)rhrrrmrrrrows zUserDict.__ior__cCs4|j|j}|j|j|jd|jd<|SNr)r\rrOrnr_r"Zinstrrrr~szUserDict.__copy__cCsX|jturt|jSddl}|j}zi|_||}W||_n||_0|||Sr)r\rrr_rn)r"r_rrrrrr_s   z UserDict.copycCrdrr)rerfr;rr+rrrrgs zUserDict.fromkeysrr)rr&r'r:rrr>rBrErr^rtrvrorr_r}rgrrrrrDs  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)rrrhrr])r"Zinitlistrrrr:s zUserList.__init__cCrrrr!rrrr^r$zUserList.__repr__cCs|j||kSrr_UserList__castrmrrrrr$zUserList.__lt__cCs|j||kSrrrmrrrrr$zUserList.__le__cCs|j||kSrrrmrrrrir$zUserList.__eq__cCs|j||kSrrrmrrrrr$zUserList.__gt__cCs|j||kSrrrmrrrrr$zUserList.__ge__cCst|tr|jS|Sr)rhrrrmrrrZ__castr$zUserList.__castcCrrrr"rrrrrr$zUserList.__contains__cCrrrr!rrrrr$zUserList.__len__cCs$t|tr||j|S|j|Sr)rhZslicer\rr"irrrr zUserList.__getitem__cCrrrr"rrrrrr>r$zUserList.__setitem__cCrrrrrrrrBr$zUserList.__delitem__cCsPt|tr||j|jSt|t|jr<||j|S||jt|Srrhrr\rrr]rmrrrr  zUserList.__add__cCsPt|tr||j|jSt|t|jr<|||jS|t||jSrrrmrrr__radd__rzUserList.__radd__cCsRt|tr|j|j7_n2t|t|jr<|j|7_n|jt|7_|Sr)rhrrrr]rmrrrrs  zUserList.__iadd__cC||j|Srr\rr"rPrrr__mul__r$zUserList.__mul__cCs|j|9_|Srrrrrr__imul__r,zUserList.__imul__cCs8|j|j}|j|j|jddd|jd<|Sr)r\rrOrnrrrrrszUserList.__copy__cC|j|dSr)rappendrrrrrr$zUserList.appendcCs|j||dSr)rinsertrrrrrr$zUserList.insertcC |j|Sr)rr?rrrrr?r$z UserList.popcCrr)rremoverrrrr r$zUserList.removecC|jdSr)rrGr!rrrrGr$zUserList.clearcCrbrrcr!rrrr_ r$z UserList.copycCr r)rrrrrrr r$zUserList.countcGs|jj|g|RSrrr)r"rrrrrrr$zUserList.indexcCr r)rrr!rrrrr$zUserList.reversecOs|jj|i|dSr)rsortr"rr8rrrr r$z UserList.sortcCs*t|tr|j|jn |j|dSr)rhrrextendrmrrrrrzUserList.extendrr)#rr&r'rxr:r^rrrirrrrrrr>rBrrrr__rmul__rrrrr?r rGr_rrrr rrrrrrs@   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)rhrrrr"Zseqrrrr:%s   zUserString.__init__cCrr)rrr!rrr__str__-r$zUserString.__str__cCrrrr!rrrr^0r$zUserString.__repr__cCrr)Zintrr!rrr__int__3r$zUserString.__int__cCrr)Zfloatrr!rrr __float__6r$zUserString.__float__cCrr)Zcomplexrr!rrr __complex__9r$zUserString.__complex__cCrr)Zhashrr!rrr__hash__<r$zUserString.__hash__cCs|jddfSrrr!rrrr?r$zUserString.__getnewargs__cCs t|tr|j|jkS|j|kSrrhrrr"ZstringrrrriB  zUserString.__eq__cCs t|tr|j|jkS|j|kSrrrrrrrGrzUserString.__lt__cCs t|tr|j|jkS|j|kSrrrrrrrLrzUserString.__le__cCs t|tr|j|jkS|j|kSrrrrrrrQrzUserString.__gt__cCs t|tr|j|jkS|j|kSrrrrrrrVrzUserString.__ge__cCst|tr|j}||jvSrr)r"Zcharrrrr[ zUserString.__contains__cCrrrr!rrrr`r$zUserString.__len__cCs||j|Srr)r"rrrrrcr$zUserString.__getitem__cCsJt|tr||j|jSt|tr6||j|S||jt|Sr)rhrr\rrrmrrrrfrzUserString.__add__cCs.t|tr|||jS|t||jSr)rhrr\rrmrrrrms zUserString.__radd__cCrrrrrrrrrr$zUserString.__mul__cCs||j|Srrr"rrrr__mod__wr$zUserString.__mod__cCs|t||Sr)r\r)r"Ztemplaterrr__rmod__zr$zUserString.__rmod__cC||jSr)r\r capitalizer!rrrr ~r$zUserString.capitalizecCrr)r\rcasefoldr!rrrr!r$zUserString.casefoldcG||jj|g|RSr)r\rcenterr"widthrrrrr#r$zUserString.centerr cC t|tr|j}|j|||Sr)rhrrrr"ZsubstartendrrrrrzUserString.countcC"t|tr|j}||j|Sr)rhrrr\ removeprefix)r"prefixrrrr+rzUserString.removeprefixcCr*r)rhrrr\ removesuffix)r"suffixrrrr-rzUserString.removesuffixutf-8strictcCs.|dur dn|}|durdn|}|j||S)Nr/r0)rencode)r"ZencodingZerrorsrrrr1szUserString.encodecC|j|||Sr)rendswith)r"r.r(r)rrrr3r$zUserString.endswithcC||j|Sr)r\r expandtabs)r"Ztabsizerrrr6r$zUserString.expandtabscCr&r)rhrrfindr'rrrr7rzUserString.findcOs|jj|i|Sr)rformatrrrrr8r$zUserString.formatcCr r)r format_map)r"rrrrr9r$zUserString.format_mapcCr2rr r'rrrrr$zUserString.indexcC |jSr)risalphar!rrrr;r$zUserString.isalphacCr:r)risalnumr!rrrr<r$zUserString.isalnumcCr:r)risasciir!rrrr=r$zUserString.isasciicCr:r)r isdecimalr!rrrr>r$zUserString.isdecimalcCr:r)risdigitr!rrrr?r$zUserString.isdigitcCr:r)rrr!rrrrr$zUserString.isidentifiercCr:r)rislowerr!rrrr@r$zUserString.islowercCr:r)r isnumericr!rrrrAr$zUserString.isnumericcCr:r)r isprintabler!rrrrBr$zUserString.isprintablecCr:r)risspacer!rrrrCr$zUserString.isspacecCr:r)ristitler!rrrrDr$zUserString.istitlecCr:r)risupperr!rrrrEr$zUserString.isuppercCr r)rrrrrrrr$zUserString.joincGr"r)r\rljustr$rrrrFr$zUserString.ljustcCrr)r\rlowerr!rrrrGr$zUserString.lowerNcCr5r)r\rlstripr"ZcharsrrrrHr$zUserString.lstripcCr r)r partitionr"seprrrrJr$zUserString.partitionrcCs6t|tr|j}t|tr |j}||j|||Sr)rhrrr\r)r"Zoldrsmaxsplitrrrrs   zUserString.replacecCr&r)rhrrrfindr'rrrrNrzUserString.rfindcCr2r)rrindexr'rrrrOr$zUserString.rindexcGr"r)r\rrjustr$rrrrPr$zUserString.rjustcCr r)r rpartitionrKrrrrQr$zUserString.rpartitioncCr5r)r\rrstriprIrrrrRr$zUserString.rstripcC|j||Sr)rrr"rLrMrrrrr$zUserString.splitcCrSr)rrsplitrTrrrrUr$zUserString.rsplitFcCr r)r splitlines)r"ZkeependsrrrrVr$zUserString.splitlinescCr2r)rr)r"r,r(r)rrrrr$zUserString.startswithcCr5r)r\rstriprIrrrrWr$zUserString.stripcCrr)r\rswapcaser!rrrrX r$zUserString.swapcasecCrr)r\rtitler!rrrrYr$zUserString.titlecGs||jj|Sr)r\r translaterrrrrZr$zUserString.translatecCrr)r\rupperr!rrrr[r$zUserString.uppercCr5r)r\rzfill)r"r%rrrr\r$zUserString.zfill)r/r0)r4rrrNrr])Fr)Krr&r'r:rr^rrrrrrirrrrrrrrrrrrrr r!r#rMZmaxsizerr+r-r1r3r6r7r8r9rr;r<r=r>r?rr@rArBrCrDrErrFrGrHrZ maketransrJrrNrOrPrQrRrrUrVrrWrXrYrZr[r\rrrrr#s         r)5rxrrZsysrMZ itertoolsr rr rr rZkeywordr rZoperatorrrlrrZreprlibrr|Z_weakrefrr4Z _collectionsrZ ImportErrorZMutableSequenceZregisterrrZKeysViewrZ ItemsViewr)Z ValuesViewr-r{r.rHrr~rrrryrrrZSequencerrrrrZsh            k/5Z