U AT^ @s&dZddddddddd g Zd d lZd d lmZmZd d lm Z d d l Z d d l Zd dlmZd dlmZmZmZd dlmZzd dlmZWnek rYnXej ezd dlm!Z!Wnek rYnXddZ"Gdddej#Z$Gdddej%Z&Gdddej'Z(Gddde)Z*Gddde+Z,zd dlm,Z,Wnek rVYnXzd dlm-Z-Wnek rd d!Z-YnXd"d d d#d$dZ.d%d&Z/zd d'lm/Z/Wnek rYnXGd(dde+Z0Gd)d d ej1Z2Gd*ddej1Z3Gd+ddejZ4Gd,ddej5Z6d S)-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 deque defaultdict namedtupleUserDictUserList UserStringCounter OrderedDictChainMapN) itemgettereq) iskeyword)proxy)repeatchainstarmap)recursive_repr)r)rcCsR|tjkr: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.9 it will stop working stacklevelzmodule z has no attribute ) _collections_abc__all__getattrwarningswarnDeprecationWarningglobalsAttributeError__name__)nameobjrr!,/usr/lib64/python3.8/collections/__init__.py __getattr__*s   r#c@seZdZddZdS)_OrderedDictKeysViewccst|jEdHdSNreversed_mappingselfr!r!r" __reversed__?sz!_OrderedDictKeysView.__reversed__Nr __module__ __qualname__r+r!r!r!r"r$=sr$c@seZdZddZdS)_OrderedDictItemsViewccs$t|jD]}||j|fVq dSr%r&r*keyr!r!r"r+Dsz"_OrderedDictItemsView.__reversed__Nr,r!r!r!r"r/Bsr/c@seZdZddZdS)_OrderedDictValuesViewccs t|jD]}|j|Vq dSr%r&r0r!r!r"r+Jsz#_OrderedDictValuesView.__reversed__Nr,r!r!r!r"r2Hsr2c@seZdZdZdS)_Link)prevnextr1 __weakref__N)rr-r. __slots__r!r!r!r"r3Nsr3c@seZdZdZd+ddZejeefddZej fddZ d d Z d d Z d dZ d,ddZ d-ddZddZejjZZddZddZddZejjZeZefddZd.dd Zed!d"Zd#d$Zd%d&Ze d/d'd(Z!d)d*Z"dS)0rz)Dictionary that remembers insertion orderr!cKs\z |jWn>tk rHt|_t|j|_}||_|_i|_YnX|j|f|dS)zInitialize an ordered dictionary. The signature is the same as regular dictionaries. Keyword argument order is preserved. N) _OrderedDict__rootrr3_OrderedDict__hardroot_proxyr4r5_OrderedDict__map_OrderedDict__update)r*otherkwdsrootr!r!r"__init__`s   zOrderedDict.__init__c CsZ||krJ||j|<}|j}|j}||||_|_|_||_|||_||||dS)z!od.__setitem__(i, y) <==> od[i]=yN)r;r8r4r5r1) r*r1valueZ dict_setitemrZLinklinkr?lastr!r!r" __setitem__ms zOrderedDict.__setitem__cCs>||||j|}|j}|j}||_||_d|_d|_dS)z od.__delitem__(y) <==> del od[y]N)r;popr4r5)r*r1Z dict_delitemrB link_prev link_nextr!r!r" __delitem__{s  zOrderedDict.__delitem__ccs(|j}|j}||k r$|jV|j}q dS)zod.__iter__() <==> iter(od)N)r8r5r1r*r?Zcurrr!r!r"__iter__s zOrderedDict.__iter__ccs(|j}|j}||k r$|jV|j}q dS)z#od.__reversed__() <==> reversed(od)N)r8r4r1rIr!r!r"r+s zOrderedDict.__reversed__cCs*|j}||_|_|jt|dS)z.od.clear() -> None. Remove all items from od.N)r8r4r5r;cleardict)r*r?r!r!r"rKs  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)KeyErrorr8r4r5r1r;rLrE)r*rCr?rBrFrGr1rAr!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;r4r5r8) r*r1rCrBrFrGZ 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;r9r8)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)r2r)r!r!r"valuesszOrderedDict.valuescCs0||kr||}||=|S||jkr,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__markerrM)r*r1defaultresultr!r!r"rEs zOrderedDict.popNcCs||kr||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*r1r]r!r!r" setdefaultszOrderedDict.setdefaultcCs*|sd|jjfSd|jjt|fS)zod.__repr__() <==> repr(od)%s()z%s(%r)) __class__rlistrZr)r!r!r"__repr__szOrderedDict.__repr__cCsDt|}ttD]}||dq|jd|p4ddt|fS)z%Return state information for picklingNr!)varscopyrrErbiterrZ)r* inst_dictkr!r!r" __reduce__ s zOrderedDict.__reduce__cCs ||S)z!od.copy() -> a shallow copy of odrbr)r!r!r"rfszOrderedDict.copycCs|}|D] }|||<q |S)zYCreate a new ordered dictionary with keys from iterable and values set to value. r!)clsiterablerAr*r1r!r!r"fromkeyss 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. ) isinstancerrL__eq__allmap_eqr*r=r!r!r"rps zOrderedDict.__eq__)r!)T)T)N)N)#rr-r.__doc__r@rLrDr:r3rHrJr+rKrNrPrXrMutableMappingupdater<rYrZr[__ne__objectr\rEr`_recursive_reprrdrjrf classmethodrnrpr!r!r!r"rQs8            )r) _tuplegettercCstt||dS)N)doc)property _itemgetter)indexr}r!r!r"7rF)renamedefaultsmodulec sttrddttttt|}|rt}t D]B\}}| rrt |sr| dsr||krd||<| |qH|gD]D}t|tk rtd| std|t |rtd|qt}D]F}| dr |s td|||kr"td|| |qi}|d k r|t|}t|tkr^td tttttt|}tttjttd d d d} ddddDdtjtttttf\d| d| d} d|d} t| | | d} d|d| d| _|d k r>|| _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 krvzt!d j"#d-d.}Wnt$tfk rtYnX|d k r||_%|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'rQ(, css|]}|dVqdS)z=%rNr!).0rr!r!r" sznamedtuple..)zdef __new__(_cls, z): return _tuple_new(_cls, (z)) namedtuple_) _tuple_newr__new__zCreate new instance of cs2||}|kr.tddt||S)Nz Expected z arguments, got ) TypeErrorrT)rlrmr^)_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: )rrE ValueErrorrc)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)rbrr))repr_fmtr!r"rdsznamedtuple..__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!) rur7r_field_defaults_fields_defaultsrrrrdrrzAlias for field number r__main__)&rostrreplacesplitrcrrrRinternset enumerate isidentifier _iskeyword startswithaddtyperrtuplerTrLr'zipreprjoinrexecru __defaults__r{__func__rr.r| _getframe f_globalsgetrr-)typenamerrrrseenrrfield_defaultsarg_lists namespacerrrrdrrmethodclass_namespacer}r^r!) rrrrrrrrrr"r9s             cCs&|j}|D]}||dd||<q dS)z!Tally elements from the iterable.r rQN)r)mappingrmZ mapping_getelemr!r!r"_count_elementssr)rcseZdZdZd/fdd ZddZd0ddZd d Zed1d d Z d2fd d Z d3ddZ ddZ ddZ fddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.ZZS)4raDict 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 tt||j|f|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)superrr@rw)r*rmr>rkr!r"r@s zCounter.__init__cCsdS)z1The count of elements not in the Counter is zero.r r!r0r!r!r" __missing__*szCounter.__missing__cCs6|dkrt|tdddStj||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)] NrQT)r1reverser1)sortedrZr_heapqnlargestr*rVr!r!r" most_common/s 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_repeatrZr)r!r!r"elements<szCounter.elementscCs tddS)Nz@Counter.fromkeys() is undefined. Use Counter(iterable) instead.)NotImplementedError)rlrmvr!r!r"rnTs zCounter.fromkeysc sr|dk r`t|tjrV|rD|j}|D]\}}|||d||<q&q`tt||n t|||rn||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 ) rorMappingrrZrrrwrr*rmr>self_getrcountrkr!r"rw`s  zCounter.updatecKsn|dk r\|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 rQ)rrorrrZsubtractrr!r!r"rs zCounter.subtractcCs ||S)zReturn a shallow copy.rkr)r!r!r"rfsz Counter.copycCs|jt|ffSr%)rbrLr)r!r!r"rjszCounter.__reduce__cs||krt|dS)zGLike dict.__delitem__() but does not raise KeyError for missing values.N)rrH)r*rrkr!r"rHszCounter.__delitem__cCsf|sd|jjSz(dtdj|}d|jj|fWStk r`d|jjt|YSXdS)Nrarz%r: %rz%s({%s})z {0}({1!r})) rbrrrr__mod__rrformatrL)r*rZr!r!r"rds zCounter.__repr__cCspt|tstSt}|D]$\}}|||}|dkr|||<q|D] \}}||krJ|dkrJ|||<qJ|S)zAdd counts from two counters. >>> Counter('abbb') + Counter('bcc') Counter({'b': 4, 'c': 2, 'a': 1}) r rorNotImplementedrZr*r=r^rrnewcountr!r!r"__add__s    zCounter.__add__cCstt|tstSt}|D]$\}}|||}|dkr|||<q|D]$\}}||krJ|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__s   zCounter.__sub__cCs|t|tstSt}|D]0\}}||}||kr8|n|}|dkr|||<q|D] \}}||krV|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"__or__s   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 rrZr*r^rrr!r!r"__pos__s  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__s 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" sz*Counter._keep_positive..)rZ)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}) rZrr*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"__ior__:s  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__Is  zCounter.__iand__)N)N)N)N)N)rr-r.rur@rrrr{rnrwrrfrjrHrdrrrrrrrrrrr __classcell__r!r!rkr"rs02  !     c@seZdZdZddZddZddZd'd d Zd d Zd dZ ddZ ddZ e ddZ eddZddZeZd(ddZeddZddZdd Zd!d"Zd#d$Zd%d&ZdS))r a 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)rcmaps)r*rr!r!r"r@kszChainMap.__init__cCs t|dSr%)rMr0r!r!r"rrszChainMap.__missing__c Cs:|jD](}z||WStk r,YqXq||Sr%)rrMr)r*r1rr!r!r" __getitem__us  zChainMap.__getitem__NcCs||kr||S|Sr%r!r_r!r!r"r}sz ChainMap.getcCsttj|jSr%)rTrunionrr)r!r!r"__len__szChainMap.__len__cCs&i}t|jD]}||qt|Sr%)r'rrwrg)r*drr!r!r"rJs zChainMap.__iter__cstfdd|jDS)Nc3s|]}|kVqdSr%r!)rmrr!r"rsz(ChainMap.__contains__..anyrr0r!rr" __contains__szChainMap.__contains__cCs t|jSr%rr)r!r!r"__bool__szChainMap.__bool__cCs"|jjddtt|jdS)Nrrr)rbrrrrrrr)r!r!r"rdszChainMap.__repr__cGs|tj|f|S)z?Create a ChainMap with a single dict created from the iterable.)rLrn)rlrmargsr!r!r"rnszChainMap.fromkeyscCs$|j|jdf|jddS)zHNew ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]r rQN)rbrrfr)r!r!r"rfsz ChainMap.copycCs|dkr i}|j|f|jS)zyNew ChainMap with a new map followed by all previous maps. If no map is provided, an empty dict is used. Nrbr)r*rr!r!r" new_childszChainMap.new_childcCs|j|jddS)zNew ChainMap from maps[1:].rQNrr)r!r!r"parentsszChainMap.parentscCs||jd|<dSNr )r)r*r1rAr!r!r"rDszChainMap.__setitem__cCs8z|jd|=Wn"tk r2td|YnXdS)Nr (Key not found in the first mapping: {!r})rrMrr0r!r!r"rHszChainMap.__delitem__cCs2z|jdWStk r,tdYnXdS)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)rrNrMr)r!r!r"rNszChainMap.popitemcGs@z|jdj|f|WStk r:td|YnXdS)zWRemove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].r rN)rrErMr)r*r1rr!r!r"rEsz ChainMap.popcCs|jddS)z'Clear maps[0], leaving maps[1:] intact.r N)rrKr)r!r!r"rKszChainMap.clear)N)N)rr-r.rur@rrrrrJrrrzrdr{rnrf__copy__rr~rrDrHrNrErKr!r!r!r"r ]s.      c@speZdZddZde_ddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ edddZdS)rcOs|s td|^}}t|dkr0tdt||r>|d}n0d|krj|d}ddl}|jdtddnd}i|_|dk r|||r||dS) Nzd?Z"dS)BrzAA more or less complete user-defined wrapper around list objects.NcCsbg|_|dk r^t|t|jkr0||jdd<n.t|trT|jdd|jdd<n t||_dSr%)rrrorrc)r*initlistr!r!r"r@s zUserList.__init__cCs t|jSr%rr)r!r!r"rd$rzUserList.__repr__cCs|j||kSr%r_UserList__castrtr!r!r"__lt__%rzUserList.__lt__cCs|j||kSr%rrtr!r!r"__le__&rzUserList.__le__cCs|j||kSr%rrtr!r!r"rp'rzUserList.__eq__cCs|j||kSr%rrtr!r!r"__gt__(rzUserList.__gt__cCs|j||kSr%rrtr!r!r"__ge__)rzUserList.__ge__cCst|tr|jS|Sr%)rorrrtr!r!r"__cast*szUserList.__castcCs ||jkSr%r r*r r!r!r"r,rzUserList.__contains__cCs t|jSr%r r)r!r!r"r-rzUserList.__len__cCs(t|tr||j|S|j|SdSr%)roslicerbrr*ir!r!r"r.s zUserList.__getitem__cCs||j|<dSr%r r*rr r!r!r"rD3rzUserList.__setitem__cCs |j|=dSr%r rr!r!r"rH4rzUserList.__delitem__cCsPt|tr||j|jSt|t|jr<||j|S||jt|Sr%rorrbrrrcrtr!r!r"r5s  zUserList.__add__cCsPt|tr||j|jSt|t|jr<|||jS|t||jSr%r!rtr!r!r"__radd__;s  zUserList.__radd__cCsRt|tr|j|j7_n2t|t|jr<|j|7_n|jt|7_|Sr%)rorrrrcrtr!r!r"rAs  zUserList.__iadd__cCs||j|Sr%rbrrr!r!r"__mul__IszUserList.__mul__cCs|j|9_|Sr%r rr!r!r"__imul__LszUserList.__imul__cCs8|j|j}|j|j|jddd|jd<|Sr)rbrrUrwrr!r!r"rOszUserList.__copy__cCs|j|dSr%)rappendrr!r!r"r&UrzUserList.appendcCs|j||dSr%)rinsertr r!r!r"r'VrzUserList.insertrcCs |j|Sr%)rrErr!r!r"rEWrz UserList.popcCs|j|dSr%)rremoverr!r!r"r(XrzUserList.removecCs|jdSr%)rrKr)r!r!r"rKYrzUserList.clearcCs ||Sr%rkr)r!r!r"rfZrz UserList.copycCs |j|Sr%)rrrr!r!r"r[rzUserList.countcGs|jj|f|Sr%rr)r*r rr!r!r"r\rzUserList.indexcCs|jdSr%)rrr)r!r!r"r]rzUserList.reversecOs|jj||dSr%)rsortr*rr>r!r!r"r*^rz UserList.sortcCs*t|tr|j|jn |j|dSr%)rorrextendrtr!r!r"r,_s zUserList.extend)N)r)#rr-r.rur@rdrrrprrrrrrrDrHrr"rr$__rmul__r%rr&r'rEr(rKrfrrrr*r,r!r!r!r"rs@  c@sheZdZddZddZddZddZd 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/d0Zd1ejfd2d3Zdd6d7Zd1ejfd8d9Z dd;d<Z!d1ejfd=d>Z"d?d@Z#dAdBZ$d1ejfdCdDZ%dEdFZ&dGdHZ'dIdJZ(dKdLZ)dMdNZ*dOdPZ+dQdRZ,dSdTZ-dUdVZ.dWdXZ/dYdZZ0d[d\Z1d]d^Z2d_d`Z3dadbZ4ddddeZ5e6j7Z7dfdgZ8ddidjZ9d1ejfdkdlZ:d1ejfdmdnZ;dodpZddudvZ?ddwdxZ@ddzd{ZAd1ejfd|d}ZBdd~dZCddZDddZEddZFddZGddZHdcS)rcCs<t|tr||_n&t|tr.|jdd|_n t||_dSr%)rorrrr*seqr!r!r"r@ls   zUserString.__init__cCs t|jSr%)rrr)r!r!r"__str__srzUserString.__str__cCs t|jSr%rr)r!r!r"rdtrzUserString.__repr__cCs t|jSr%)intrr)r!r!r"__int__urzUserString.__int__cCs t|jSr%)floatrr)r!r!r" __float__vrzUserString.__float__cCs t|jSr%)complexrr)r!r!r" __complex__wrzUserString.__complex__cCs t|jSr%)hashrr)r!r!r"__hash__xrzUserString.__hash__cCs|jddfSr%r r)r!r!r"ryszUserString.__getnewargs__cCs t|tr|j|jkS|j|kSr%rorrr*stringr!r!r"rp|s  zUserString.__eq__cCs t|tr|j|jkS|j|kSr%r9r:r!r!r"rs  zUserString.__lt__cCs t|tr|j|jkS|j|kSr%r9r:r!r!r"rs  zUserString.__le__cCs t|tr|j|jkS|j|kSr%r9r:r!r!r"rs  zUserString.__gt__cCs t|tr|j|jkS|j|kSr%r9r:r!r!r"rs  zUserString.__ge__cCst|tr|j}||jkSr%r9)r*charr!r!r"rs zUserString.__contains__cCs t|jSr%r r)r!r!r"rrzUserString.__len__cCs||j|Sr%r#)r*rr!r!r"rrzUserString.__getitem__cCsJt|tr||j|jSt|tr6||j|S||jt|Sr%)rorrbrrrtr!r!r"rs   zUserString.__add__cCs.t|tr|||jS|t||jSr%)rorrbrrtr!r!r"r"s zUserString.__radd__cCs||j|Sr%r#rr!r!r"r$szUserString.__mul__cCs||j|Sr%r#r*rr!r!r"rszUserString.__mod__cCs|t||Sr%)rbr)r*templater!r!r"__rmod__szUserString.__rmod__cCs||jSr%)rbr capitalizer)r!r!r"r@rzUserString.capitalizecCs||jSr%)rbrcasefoldr)r!r!r"rAszUserString.casefoldcGs||jj|f|Sr%)rbrcenterr*widthrr!r!r"rBszUserString.centerr cCs t|tr|j}|j|||Sr%)rorrrr*substartendr!r!r"rs zUserString.countutf-8strictcCs.|dkr dn|}|dkrdn|}|j||S)NrIrJ)rencode)r*encodingerrorsr!r!r"rKszUserString.encodecCs|j|||Sr%)rendswith)r*suffixrGrHr!r!r"rNszUserString.endswithcCs||j|Sr%)rbr expandtabs)r*tabsizer!r!r"rQszUserString.expandtabscCs t|tr|j}|j|||Sr%)rorrfindrEr!r!r"rSs zUserString.findcOs|jj||Sr%)rrr+r!r!r"rszUserString.formatcCs |j|Sr%)r format_map)r*rr!r!r"rTszUserString.format_mapcCs|j|||Sr%r)rEr!r!r"rszUserString.indexcCs |jSr%)risalphar)r!r!r"rUrzUserString.isalphacCs |jSr%)risalnumr)r!r!r"rVrzUserString.isalnumcCs |jSr%)risasciir)r!r!r"rWrzUserString.isasciicCs |jSr%)r isdecimalr)r!r!r"rXrzUserString.isdecimalcCs |jSr%)risdigitr)r!r!r"rYrzUserString.isdigitcCs |jSr%)rrr)r!r!r"rrzUserString.isidentifiercCs |jSr%)rislowerr)r!r!r"rZrzUserString.islowercCs |jSr%)r isnumericr)r!r!r"r[rzUserString.isnumericcCs |jSr%)r isprintabler)r!r!r"r\rzUserString.isprintablecCs |jSr%)risspacer)r!r!r"r]rzUserString.isspacecCs |jSr%)ristitler)r!r!r"r^rzUserString.istitlecCs |jSr%)risupperr)r!r!r"r_rzUserString.isuppercCs |j|Sr%)rrr.r!r!r"rrzUserString.joincGs||jj|f|Sr%)rbrljustrCr!r!r"r`szUserString.ljustcCs||jSr%)rbrlowerr)r!r!r"rarzUserString.lowerNcCs||j|Sr%)rbrlstripr*charsr!r!r"rbrzUserString.lstripcCs |j|Sr%)r partitionr*sepr!r!r"reszUserString.partitionrcCs6t|tr|j}t|tr |j}||j|||Sr%)rorrrbr)r*oldnewmaxsplitr!r!r"rs   zUserString.replacecCs t|tr|j}|j|||Sr%)rorrrfindrEr!r!r"rks zUserString.rfindcCs|j|||Sr%)rrindexrEr!r!r"rlszUserString.rindexcGs||jj|f|Sr%)rbrrjustrCr!r!r"rmszUserString.rjustcCs |j|Sr%)r rpartitionrfr!r!r"rnszUserString.rpartitioncCs||j|Sr%)rbrrstriprcr!r!r"roszUserString.rstripcCs|j||Sr%)rrr*rgrjr!r!r"rszUserString.splitcCs|j||Sr%)rrsplitrpr!r!r"rqszUserString.rsplitFcCs |j|Sr%)r splitlines)r*keependsr!r!r"rrrzUserString.splitlinescCs|j|||Sr%)rr)r*prefixrGrHr!r!r"rszUserString.startswithcCs||j|Sr%)rbrstriprcr!r!r"rurzUserString.stripcCs||jSr%)rbrswapcaser)r!r!r"rvrzUserString.swapcasecCs||jSr%)rbrtitler)r!r!r"rwrzUserString.titlecGs||jj|Sr%)rbr translater=r!r!r"rxszUserString.translatecCs||jSr%)rbrupperr)r!r!r"ryrzUserString.uppercCs||j|Sr%)rbrzfill)r*rDr!r!r"rzrzUserString.zfill)rIrJ)rP)N)r)N)Nr)Nr)F)N)Irr-r.r@r0rdr2r4r6r8rrprrrrrrrrr"r$r-rr?r@rArBrRmaxsizerrKrNrQrSrrTrrUrVrWrXrYrrZr[r\r]r^r_rr`rarbr maketransrerrkrlrmrnrorrqrrrrurvrwrxryrzr!r!r!r"rks         )7rurroperatorr rr rskeywordr rsysrRheapqr_weakrefrr: itertoolsrrrrrrreprlibrrz _collectionsr ImportErrorMutableSequenceregisterrr#KeysViewr$ ItemsViewr/ ValuesViewr2ryr3rLrr|rrrrvr rrSequencerr!r!r!r"sh     Y&vnMS