=Og2dZgdZddlZddlZddlmZddlmZ ddlm Z ddl m ZddlmZdd lmZdd lmZdd lmZ dd lmZejen #e$rYnwxYw dd lmZn #e$rYnwxYwGddej Z!Gddej"Z#Gddej$Z%Gdde&Z'Gdde(Z) ddlm)Z)n #e$rYnwxYw ddlm*Z*n#e$rdZ*YnwxYwdddddZ+dZ, ddlm,Z,n #e$rYnwxYwGd d!e(Z-Gd"d#ej.Z/Gd$d%ej.Z0Gd&d'ejZ1Gd(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 )rceZdZdZdS)_OrderedDictKeysViewc#>Kt|jEd{VdSNreversed_mappingselfs ;/opt/alt/python311/lib64/python3.11/collections/__init__.py __reversed__z!_OrderedDictKeysView.__reversed__<s.DM***********N__name__ __module__ __qualname__rrrrr:s#+++++rrceZdZdZdS)_OrderedDictItemsViewc#ZKt|jD]}||j|fVdSrrrkeys rrz"_OrderedDictItemsView.__reversed__AsDDM** , ,C c*+ + + + + , ,rNr r$rrr&r&?s#,,,,,rr&ceZdZdZdS)_OrderedDictValuesViewc#VKt|jD]}|j|VdSrrr(s rrz#_OrderedDictValuesView.__reversed__Gs?DM** % %C-$ $ $ $ $ % %rNr r$rrr+r+Es#%%%%%rr+ceZdZdZdS)_Link)prevnextr) __weakref__N)r!r"r# __slots__r$rrr.r.Ks4IIIrr.cBeZdZdZdZddZejee fdZej fdZ dZ dZ d Z dd Zdd Zd ZejjxZZdZdZdZejjZeZefdZddZedZdZdZ e!ddZ"dZ#dZ$dZ%dZ&dS)rz)Dictionary that remembers insertion orderct|}t|_t |jx|_}|x|_|_i|_|S)zDCreate the ordered dict object and set up the underlying structures.) dict__new__r._OrderedDict__hardroot_proxy_OrderedDict__rootr/r0_OrderedDict__map)clsargskwdsrroots rr6zOrderedDict.__new__]sN||C  ''#DO444 d $$ DI  rr$c "|j|fi|dS)zInitialize an ordered dictionary. The signature is the same as regular dictionaries. Keyword argument order is preserved. N)_OrderedDict__update)rotherr=s r__init__zOrderedDict.__init__fs$  e$$t$$$$$rc||vrO|x|j|<}|j}|j}|||c|_|_|_||_|||_||||dS)z!od.__setitem__(i, y) <==> od[i]=yN)r:r9r/r0r)) rr)value dict_setitemrLinklinkr>lasts r __setitem__zOrderedDict.__setitem__lsw d??%)TVV +DJsOd;D9D-14 *DIty$(DId DI T3&&&&&rc||||j|}|j}|j}||_||_d|_d|_dS)z od.__delitem__(y) <==> del od[y]N)r:popr/r0)rr) dict_delitemrG link_prev link_nexts r __delitem__zOrderedDict.__delitem__zsW  T3z~~c""I I " "   rc#ZK|j}|j}||ur|jV|j}||udSdS)zod.__iter__() <==> iter(od)N)r9r0r)rr>currs r__iter__zOrderedDict.__iter__L{y$(NNN9D$rc#ZK|j}|j}||ur|jV|j}||udSdS)z#od.__reversed__() <==> reversed(od)N)r9r/r)rQs rrzOrderedDict.__reversed__rTrc|j}|x|_|_|jt |dS)z.od.clear() -> None. Remove all items from od.N)r9r/r0r:clearr5)rr>s rrWzOrderedDict.clearsC{ $$ DI  4rTc|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)KeyErrorr9r/r0r)r:r5rK)rrHr>rGrMrNr)rDs rpopitemzOrderedDict.popitems  2011 1{  "9D I!IN!DII9D I!DI!INh JsOs##Ezrc|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)r:r/r0r9) rr)rHrGrMrN soft_linkr>firsts r move_to_endzOrderedDict.move_to_ends z#I I N " " {  9DDIDI!DIDIIIIEDIDI"EJDIIIrctj}t|dz}||j}|||jdzz }|||j|zz }|||j|zz }|S)N)_sys getsizeoflen__dict__r:r7r9)rsizeofnsizes r __sizeof__zOrderedDict.__sizeof__s IIMvdm$$ tz""Q&& t''!++ t{##a'' rc t|S)z:D.keys() -> a set-like object providing a view on D's keys)rrs rkeyszOrderedDict.keyss#D)))rc t|S)z a set-like object providing a view on D's items)r&rs ritemszOrderedDict.itemss$T***rc t|S)z6D.values() -> an object providing a view on D's values)r+rs rvalueszOrderedDict.valuess%d+++rc|j}t|||}||urF|j|}|j}|j}||_||_d|_d|_|S||urt ||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. N)_OrderedDict__markerr5rKr:r/r0rY)rr)defaultmarkerresultrGrMrNs rrKzOrderedDict.pops $V,,   :>>#&&D I I&IN&INDIDIM f  3-- rNc(||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$rr)rrs r setdefaultzOrderedDict.setdefaults% $;;9 S rc|s|jjdS|jjdt|dS)zod.__repr__() <==> repr(od)()()) __class__r!listrmrs r__repr__zOrderedDict.__repr__ sL 7!^4446 6>222D4F4F4F4FGGrc|}|rt|tr|\}}ni}|}|}t t D].}||d||d/|r||f}n|pd}|jd|dt| fS)z%Return state information for picklingNr$) __getstate__ isinstancetuplecopyvarsrrKr|iterrm)rstateslotsks r __reduce__zOrderedDict.__reduce__s!!##  &%'' $ uuJJLLEJJLLE+--(( # # !T""" !T"""" &u  ~r5$TZZ\\0B0BBBrc,||S)z!od.copy() -> a shallow copy of odr|rs rrzOrderedDict.copy%~~d###rc.|}|D]}|||<|S)zYCreate a new ordered dictionary with keys from iterable and values set to value. r$)r;iterablerDrr)s rfromkeyszOrderedDict.fromkeys)s.suu  CDII rct|tr>t||o"t t t ||St||S)zod.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive. )rrr5__eq__allmap_eqrrAs rrzOrderedDict.__eq__2sX e[ ) ) K;;tU++JCT54I4I0J0J J{{4'''rc0|||Sr)updaters r__ior__zOrderedDict.__ior__;s E rct|tstS||}|||Srrr5NotImplementedr|rrrAnews r__or__zOrderedDict.__or__?sB%&& "! !nnT"" 5 rct|tstS||}|||Srrrs r__ror__zOrderedDict.__ror__FsB%&& "! !nnU## 4 r)r$)Tr)'r!r"r#__doc__r6rBr5rIr8r.rOrSrrWrZr^ri_collections_abcMutableMappingrr@rkrmro__ne__objectrqrKrw_recursive_reprr~rr classmethodrrrrrr$rrrrNs//%%%%"&!1e ' ' ' '-1,<    .2)7>>FX***+++,,, , 3FvxxH',_HHH CCC&$$$[(((rr)r) _tuplegetterc>tt||S)N)doc)property _itemgetter)indexrs rr\sh{5/A/As&K&K&KrF)renamedefaultsmodulec  ttr(ddt t tt jt|}|r|t}tD]^\}}| r(t|s| ds||vrd||<| |_|gzD]n}t|turtd| st!d|t|rt!d|ot}D]V}| dr|st!d|||vrt!d|| |Wi}|t#|}t%|t%krtd t't)t t+t)t)|}t#t t jt%d } d kr| dz } d d dDzdzt"jt&t"t$t t*f\id|d} d| d| d} t1| | } d| _d|d | d| _||| _t8fd} d|d| j_fd}d|d|_fd}fd}fd}| | j||||fD]}|d |j|_|d | dd!|| | ||||d" }tD]/\}}t jd#|}t?||||<0t|t"f|}|F t j d j!"d$d%}n#tFt f$rYnwxYw|||_$|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, r`rzc3 K|] }|dV dS)z=%rNr$).0names r znamedtuple..s(DD$|||DDDDDDrr{ namedtuple_) _tuple_new __builtins__r!z lambda _cls, z: _tuple_new(_cls, (z))r6zCreate new instance of c||}|kr"tddt||S)Nz Expected z arguments, got ) TypeErrorrd)r;rrt_len num_fields tuple_news r_makeznamedtuple.._makesQ3)) 4<<: % %Q QQCKKQQRR R rz Make a new z# object from a sequence or iterablec||j|}|rtdt||S)NzGot unexpected field names: )rrK ValueErrorr})rr=rt_map field_namess r_replaceznamedtuple.._replacesODD;==>>  LJDJJJJKK K rz Return a new z2 object replacing specified fields with new valuesc(|jj|zzS)z/Return a nicely formatted representation string)r|r!)rrepr_fmts rr~znamedtuple..__repr__s~&D88rc8|j|S)z9Return a new dict which maps field names to their values.)_fields)r_dict_zips r_asdictznamedtuple.._asdicts!uTT$,--...rc|S)z7Return self as a plain tuple. Used by copy and pickle.r$)r_tuples r__getnewargs__z"namedtuple..__getnewargs__svd||r.r$) rr2r_field_defaultsr6rrr~rr__match_args__zAlias for field number r!__main__)%rstrreplacesplitr}rrbinternset enumerate isidentifier _iskeyword startswithaddtyperrrrdr5rzipjoinr6evalr!r __defaults__r__func__r#r _getframe f_globalsgetAttributeErrorr")typenamerrrrseenrrfield_defaultsarg_list namespacecoder6rrr~rrmethodclass_namespacerrtrrrrrrrrs ` @@@@@@@@rr r ^s4+s##<!))#s3399;; s3 ,,--K{3x==))H uu$[11  KE4%%'' 1d## 1??3'' 14<<%0[[ E" HHTNNNN [(33 ::S HII I  "" 76-16677 7 d   32)-2233 3 3 55D ??3   * *) $))** * 4<<J$JJKK K N?? x==3{++ + +FGG GhtC0E0E080B0B-D-D(E(EFFGGDK5566K[!!Jyy%%HQCTYYDD DDDDDDsJH I&*E3S&@#E64t  ,(,,I F8 E E E E ED4##G GFFF8FFFGO'[ ,H,,,EN 1111H99999//////   >>"*==FO== ,,,,,)(%  O!--99 tk;E;;<< ,UC 8 8 (UHo 6 6F~ ^A&&044ZLLFF +    D  " Ms7-Q%%Q98Q9cB|j}|D]}||ddz||<dS)z!Tally elements from the iterable.r r`N)r)mappingr mapping_getelems r_count_elementsr s>+K11# D!,,q0 11r)rceZdZdZd fd ZdZdZd dZdZe d dZ d fd Z d d Z d Z d Zfd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!xZ"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 dt|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)superrBr)rrr=r|s rrBzCounter.__init__Ks;  H%%%%%%%rcdS)z1The count of elements not in the Counter is zero.r r$r(s r __missing__zCounter.__missing__Ys qrcDt|S)zSum of the counts)sumrors rtotalz Counter.total^s4;;==!!!rc|1t|tddSddl}|||tdS)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)] Nr`T)r)reverser )r))sortedrmrheapqnlargest)rrgrs r most_commonzCounter.most_commonbs] 9$**,,KNNDIII I  ~~a;q>>~BBBrcttjtt|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 >>> import math >>> prime_factors = Counter({2: 2, 3: 3, 17: 1}) >>> math.prod(prime_factors.elements()) 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_repeatrmrs relementszCounter.elementsrs'$#HWdjjll$C$CDDDrc td)Nz@Counter.fromkeys() is undefined. Use Counter(iterable) instead.)NotImplementedError)r;rvs rrzCounter.fromkeyss" NPP Prc B|t|tjrX|r4|j}|D]\}}|||dz||<n2t |nt|||r||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 )rrMappingrrmrrr)rrr=self_getrcountr|s rrzCounter.updates(  ($4$<== 0-#xH'/~~'7'7?? e%*XXdA->->%>T ?GGNN8,,,,h///   KK       rc |e|j}t|tjr-|D]\}}||d|z ||<n|D]}||ddz ||<|r||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 r`)rrrrrmsubtract)rrr=rrrs rrzCounter.subtracts  xH($4$<== 7#+>>#3#3;;KD%!)$!2!2U!:DJJ;%77D!)$!2!2Q!6DJJ  MM$       rc,||S)zReturn a shallow copy.rrs rrz Counter.copyrrc0|jt|ffSr)r|r5rs rrzCounter.__reduce__s~T },,rcV||vr#t|dSdS)zGLike dict.__delitem__() but does not raise KeyError for missing values.N)rrO)rrr|s rrOzCounter.__delitem__s1 4<< GG   % % % % % .=II1qII!47eAh&IIIIIIIrrrrrrs``rrzCounter.__eq__ F%)) "! !IIIIIu IIIIIIrcHt|tstS||k S)z@True if any counts disagree. Missing counts are treated as zero.rrrrs rrzCounter.__ne__s'%)) "! !5=  rczttstStfdfDS)z:True if all counts in self are a subset of those in other.c3FK|]}|D]}||kVdSrr$rs rrz!Counter.__le__..rrr rs``r__le__zCounter.__le__r!rcRt|tstS||ko||kS)zATrue if all counts in self are a proper subset of those in other.r#rs r__lt__zCounter.__lt__-%)) "! !u}..rczttstStfdfDS)z.&rrr rs``r__ge__zCounter.__ge__"r!rcRt|tstS||ko||kS)zCTrue if all counts in self are a proper superset of those in other.r#rs r__gt__zCounter.__gt__(r)rc t|tstSt}|D]\}}|||z}|dkr|||<|D]\}}||vr |dkr|||<|S)zAdd counts from two counters. >>> Counter('abbb') + Counter('bcc') Counter({'b': 4, 'c': 2, 'a': 1}) r rrrrmrrArtrrnewcounts r__add__zCounter.__add__.s%)) "! !::<< ( (KD%uT{*H!||'t  ;;== % %KD%4EAII$t  rct|tstSt}|D]\}}|||z }|dkr|||<|D]\}}||vr|dkrd|z ||<|S)z Subtract count, but keep only results with positive counts. >>> Counter('abbbc') - Counter('bccd') Counter({'b': 2, 'a': 1}) r r0r1s r__sub__zCounter.__sub__As%)) "! !::<< ( (KD%uT{*H!||'t  ;;== ) )KD%4EAII 5yt  rct|tstSt}|D]"\}}||}||kr|n|}|dkr|||<#|D]\}}||vr |dkr|||<|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 r0rrArtrr other_countr2s rrzCounter.__or__Ts%)) "! !::<< ( (KD%+K&+k&9&9{{uH!||'t  ;;== % %KD%4EAII$t  rct|tstSt}|D]"\}}||}||kr|n|}|dkr|||<#|S)z Intersection is the minimum of corresponding counts. >>> Counter('abbb') & Counter('bcc') Counter({'b': 1}) r r0r7s r__and__zCounter.__and__hst%)) "! !::<< ( (KD%+K % 3 3uuH!||'t  rclt}|D]\}}|dkr|||<|S)zEAdds an empty counter, effectively stripping negative and zero countsr rrmrrtrrs r__pos__zCounter.__pos__ys>::<< % %KD%qyy$t  rcrt}|D]\}}|dkrd|z ||<|S)z{Subtracts from an empty counter. Strips positive and zero counts, and flips the sign on negative counts. r r<r=s r__neg__zCounter.__neg__sD ::<< ) )KD%qyy 5yt  rcRd|D}|D]}||=|S)z?Internal method to strip elements with a negative or zero countc$g|] \}}|dk |S)r r$)rrrs r z*Counter._keep_positive..s!MMM e5199t999r)rm)r nonpositivers r_keep_positivezCounter._keep_positives:MMtzz||MMM   DT  rc~|D]\}}||xx|z cc<|S)zInplace add from another counter, keeping only positive counts. >>> c = Counter('abbb') >>> c += Counter('bcc') >>> c Counter({'b': 4, 'c': 2, 'a': 1}) rmrErrArrs r__iadd__zCounter.__iadd__I!;;==  KD% JJJ% JJJJ""$$$rc~|D]\}}||xx|zcc<|S)zInplace subtract counter, but keep only results with positive counts. >>> c = Counter('abbbc') >>> c -= Counter('bccd') >>> c Counter({'b': 2, 'a': 1}) rGrHs r__isub__zCounter.__isub__rJrc|D]\}}||}||kr|||<|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}) rG)rrArr8rs rrzCounter.__ior__sP"' ) ) D+JEU""(T ""$$$rc|D]\}}||}||kr|||<|S)zInplace intersection is the minimum of corresponding counts. >>> c = Counter('abbb') >>> c &= Counter('bcc') >>> c Counter({'b': 1}) rG)rrArrr8s r__iand__zCounter.__iand__sO ::<< ) )KD%+KU""(T ""$$$rr)#r!r"r#rrBrrrr rrrrrrrOr~rrr&r(r,r.r3r5rr:r>r@rErIrLrrO __classcell__rs@rrrs6**d & & & & & & """CCCC EEE, P P P[ P      D    6$$$---&&&&& 3 3 3ZJJJ !!! JJJ /// JJJ /// &&("    % % % % % % % % % % % % % % % %rrceZdZdZdZdZdZddZdZdZ d Z d Z e d Z ed Zd ZeZddZedZdZdZdZdZdZdZdZdZdS)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. c4t|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)rrSs rrBzChainMap.__init__s JJ&2$ rc t|r)rYr(s rrzChainMap.__missing__ssmmrct|jD]} ||cS#t$rYwxYw||Sr)rSrYr)rr)rs r __getitem__zChainMap.__getitem__s\y  G s|###    $$$s  ""Nc||vr||n|Srr$rvs rrz ChainMap.gets4KKtCyyW4rcRttj|jSr)rdrunionrSrs r__len__zChainMap.__len__s;355; *+++rci}t|jD]/}|t|0t |Sr)rrSrr5rr)rrrs rrSzChainMap.__iter__sL  ** - -G HHT]]7++ , , , ,AwwrcDtfd|jDS)Nc3 K|]}|vV dSrr$)rmr)s rrz(ChainMap.__contains__..s'//3!8//////ranyrSr(s `r __contains__zChainMap.__contains__s(////TY//////rc*t|jSrr_rs r__bool__zChainMap.__bool__49~~rc||jjddtt|jdS)Nrzrr{)r|r!rrreprrSrs rr~zChainMap.__repr__s6.)NNDIIc$ 6J6J,K,KNNNNrc8|tj|g|RS)z?Create a ChainMap with a single dict created from the iterable.)r5r)r;rr<s rrzChainMap.fromkeyss&s4=1D111222rcr|j|jdg|jddRS)zHNew ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]r r`N)r|rSrrs rrz ChainMap.copy s8t~dil//11BDIabbMBBBBrc `||}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. )rr|rS)rr^kwargss r new_childzChainMap.new_childsF 9AA   HHV   t~a,$),,,,rc0|j|jddS)zNew ChainMap from maps[1:].r`N)r|rSrs rparentszChainMap.parentsst~ty}--rc&||jd|<dSNr )rS)rr)rDs rrIzChainMap.__setitem__!s! ! Srcd |jd|=dS#t$rtd|wxYw)Nr $Key not found in the first mapping: )rSrYr(s rrOzChainMap.__delitem__$sR K ! S!!! K K KI#IIJJ J Ks/c| |jdS#t$rtdwxYw)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.)rSrZrYrs rrZzChainMap.popitem*sN B9Q<'')) ) B B B@AA A Bs!;cv |jdj|g|RS#t$rtd|wxYw)zWRemove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].r rq)rSrKrY)rr)r<s rrKz ChainMap.pop1s_ K#49Q<#C/$/// / K K KI#IIJJ J Ks8cD|jddS)z'Clear maps[0], leaving maps[1:] intact.r N)rSrWrs rrWzChainMap.clear8s  ! rcF|jd||Sro)rSrrs rrzChainMap.__ior__<s! ! E""" rct|tjstS|}|jd||Sro)rrrrrrSr)rrAr^s rrzChainMap.__or__@sJ%!1!9:: "! ! IIKK q rct|tjstSt |}t |jD]}||||Sr) rrrrr5rrSrr|)rrAr^childs rrzChainMap.__ror__Gse%!1!9:: "! ! KKdi((  E HHUOOOO~~a   rr)r!r"r#rrBrrVrrZrSrarcrr~rrr__copy__rkrrmrIrOrZrKrWrrrr$rrrrs  '''%%%5555,,, 000_OOO33[3CCCH - - - -..X."""KKK BBBKKK!!!!!rrcveZdZddZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZeddZdS)rNc ti|_||||r||dSdSr)datar)rr5rjs rrBzUserDict.__init__WsK   KK     KK       rc*t|jSrrdr|rs rrZzUserDict.__len__^rdrc||jvr |j|St|jdr|j||St |)Nr)r|hasattrr|rrYr(s rrVzUserDict.__getitem__asS $)  9S> ! 4>= 1 1 9>--dC88 8smmrc||j|<dSrr|)rr)items rrIzUserDict.__setitem__hs #rc|j|=dSrrr(s rrOzUserDict.__delitem__ks IcNNNrc*t|jSr)rr|rs rrSzUserDict.__iter__nDIrc||jvSrrr(s rrazUserDict.__contains__rsdirc*t|jSrrfr|rs rr~zUserDict.__repr__vrrct|tr"||j|jzSt|tr||j|zSt Srrrr|r|r5rrs rrzUserDict.__or__ys` eX & & :>>$)ej"899 9 eT " " 5>>$)e"344 4rct|tr"||j|jzSt|tr|||jzSt Srrrs rrzUserDict.__ror__s` eX & & :>>%*ty"899 9 eT " " 5>>%$)"344 4rc|t|tr|xj|jzc_n|xj|zc_|Sr)rrr|rs rrzUserDict.__ior__s= eX & &  II #III II II rc|j|j}|j|j|jd|jd<|SNr|)r|r6rerrrinsts rryzUserDict.__copy__sU~%%dn55 T]+++ $ f 5 : : < < f rc|jtur&t|jSddl}|j} i|_||}||_n #||_wxYw|||Sro)r|rr|rr)rrr|rs rrz UserDict.copys >X % %DINN,,-- - y DI $ADIIDI     s A%% A.c.|}|D]}|||<|Srr$)r;rrDrr)s rrzUserDict.fromkeyss, CEE  CAcFFrr)r!r"r#rBrZrVrIrOrSrar~rrrryrrrr$rrrrTs          [rrceZdZdZd"dZdZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZeZdZdZdZdZd#dZdZdZdZdZdZdZ d Z!d!Z"dS)$rzAA more or less complete user-defined wrapper around list objects.Nc g|_|yt|t|jkr||jdd<dSt|tr|jdd|jdd<dSt ||_dSdSr)r|rrrr})rinitlists rrBzUserList.__init__s  H~~di00' !!! Hh// +'}QQQ/ !!!  NN  rc*t|jSrrrs rr~zUserList.__repr__rrc>|j||kSrr|_UserList__castrs rr(zUserList.__lt__y4;;u----rc>|j||kSrrrs rr&zUserList.__le__yDKK....rc>|j||kSrrrs rrzUserList.__eq__rrc>|j||kSrrrs rr.zUserList.__gt__rrc>|j||kSrrrs rr,zUserList.__ge__rrc>t|tr|jn|Sr)rrr|rs r__castzUserList.__casts'x88CuzzeCrc||jvSrrrrs rrazUserList.__contains__sty  rc*t|jSrr~rs rrZzUserList.__len__rdrct|tr ||j|S|j|Sr)rslicer|r|ris rrVzUserList.__getitem__s8 a   >>$)A,// /9Q< rc||j|<dSrrrrrs rrIzUserList.__setitem__s ! rc|j|=dSrrrs rrOzUserList.__delitem__s IaLLLrcBt|tr"||j|jzSt|t |jr||j|zS||jt |zSrrrr|r|rr}rs rr3zUserList.__add__s eX & & 5>>$)ej"899 9 tDI / / 5>>$)e"344 4~~di$u++5666rcBt|tr"||j|jzSt|t |jr|||jzS|t ||jzSrrrs r__radd__zUserList.__radd__s eX & & 5>>%*ty"899 9 tDI / / 5>>%$)"344 4~~d5kkDI5666rct|tr|xj|jz c_nPt|t|jr|xj|z c_n|xjt |z c_|Sr)rrr|rr}rs rrIzUserList.__iadd__so eX & & % II #III tDI / / % II III IIe $II rc<||j|zSrr|r|rrgs r__mul__zUserList.__mul__~~di!m,,,rc&|xj|zc_|Srrrs r__imul__zUserList.__imul__s Q  rc|j|j}|j|j|jddd|jd<|Sr)r|r6rerrs rryzUserList.__copy__sR~%%dn55 T]+++ $ f 5aaa 8 f rc:|j|dSr)r|appendrs rrzUserList.append  rc<|j||dSr)r|insertrs rrzUserList.insert s  D!!!!!rc6|j|Sr)r|rKrs rrKz UserList.popsy}}Qrc:|j|dSr)r|removers rrzUserList.removerrc8|jdSr)r|rWrs rrWzUserList.clears rc,||Srrrs rrz UserList.copys~~d###rc6|j|Sr)r|rrs rrzUserList.countsyt$$$rc(|jj|g|RSrr|r)rrr<s rrzUserList.indexstyt+d++++rc8|jdSr)r|rrs rrzUserList.reverse"s rc*|jj|i|dSr)r|sortrr<r=s rrz UserList.sort%s! %%%%%%rct|tr!|j|jdS|j|dSr)rrr|extendrs rrzUserList.extend(sN eX & & $ I  UZ ( ( ( ( ( I  U # # # # #rrr)#r!r"r#rrBr~r(r&rr.r,rrarZrVrIrOr3rrIr__rmul__rryrrrKrrWrrrrrrr$rrrrsKK + + + +...//////...///DDD!!!   777777---H"""    $$$%%%,,,&&&$$$$$rrc4eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZeZdZdZdZdZdZdejfdZdZdZ dKdZ!dejfd Z"dLd"Z#dejfd#Z$d$Z%d%Z&dejfd&Z'd'Z(d(Z)d)Z*d*Z+d+Z,d,Z-d-Z.d.Z/d/Z0d0Z1d1Z2d2Z3d3Z4d4Z5d5Z6dMd7Z7e8j9Z9d8Z:dNd:Z;dejfd;Zd>Z?dMd?Z@dOd@ZAdOdAZBdPdCZCdejfdDZDdMdEZEdFZFdGZGdHZHdIZIdJZJd6S)Qrct|tr ||_dSt|tr|jdd|_dSt||_dSr)rrr|rrseqs rrBzUserString.__init__5sW c3   !DIII Z ( ( ! DIIICDIIIrc*t|jSr)rr|rs r__str__zUserString.__str__=rdrc*t|jSrrrs rr~zUserString.__repr__@rrc*t|jSr)intr|rs r__int__zUserString.__int__Crdrc*t|jSr)floatr|rs r __float__zUserString.__float__FsTYrc*t|jSr)complexr|rs r __complex__zUserString.__complex__Isty!!!rc*t|jSr)hashr|rs r__hash__zUserString.__hash__Lrrc"|jddfSrrrs rrzUserString.__getnewargs__Os !!! rcbt|tr|j|jkS|j|kSrrrr|rstrings rrzUserString.__eq__R0 fj ) ) ,9 + +yF""rcbt|tr|j|jkS|j|kSrrrs rr(zUserString.__lt__W0 fj ) ) +9v{* *y6!!rcbt|tr|j|jkS|j|kSrrrs rr&zUserString.__le__\rrcbt|tr|j|jkS|j|kSrrrs rr.zUserString.__gt__arrcbt|tr|j|jkS|j|kSrrrs rr,zUserString.__ge__frrcLt|tr|j}||jvSrr)rchars rrazUserString.__contains__ks( dJ ' ' 9Dty  rc*t|jSrr~rs rrZzUserString.__len__prdrcB||j|Srr)rrs rrVzUserString.__getitem__ss~~di.///rc(t|tr"||j|jzSt|tr||j|zS||jt |zSr)rrr|r|rrs rr3zUserString.__add__vsy eZ ( ( 5>>$)ej"899 9 s # # 5>>$)e"344 4~~di#e**4555rct|tr|||jzS|t||jzSr)rrr|r|rs rrzUserString.__radd__}sL eS ! ! 5>>%$)"344 4~~c%jj494555rc<||j|zSrrrs rrzUserString.__mul__rrc<||j|zSrrrr<s r__mod__zUserString.__mod__s~~di$.///rcL|t||zSr)r|r)rtemplates r__rmod__zUserString.__rmod__s~~c(mmd2333rcZ||jSr)r|r| capitalizers rrzUserString.capitalizes"~~di2244555rcZ||jSr)r|r|casefoldrs rrzUserString.casefold"~~di0022333rcN||jj|g|RSr)r|r|centerrwidthr<s rrzUserString.centers,~~.di.u>> !dl0000 >>> >>> 2222 &'DL6666==== T\//// ///--- !dl0000#########%%%###(((###%%%'''############===1117777 I(((EEEE !dl0000 !"t|1111===)))7777....////....()dl88886666444111:::11166666rr)4r__all__rsysrb itertoolsr rr r rr keywordrroperatorrrrrreprlibrr_weakrefrr8 _collectionsr MutableSequenceregister ImportErrorrKeysViewr ItemsViewr& ValuesViewr+rr.r5rrr rrrrrrSequencerr$rrrsK   %%%%%%''''''))))))++++++......555555$$$$$$5""""""$--e4444   D  (((((((   D ++++++4+++ ,,,,,,6,,, %%%%%-8%%% 55555F555}}}}}$}}}@ (((((((   D L)))))))LLLKKLLLL16Thhhhh^111  ,,,,,,,   D q%q%q%q%q%dq%q%q%p }!}!}!}!}!.}!}!}!HSSSSS.SSSt~$~$~$~$~$/~$~$~$Ju6u6u6u6u6!*u6u6u6u6u6sZA!!A)(A)-A44A<;A<CC$#C$(C//C:9C: DDD