\ddZgdZddlZddlZddlmZddlmZ 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 BJ:\tools\MySQL Workbench 8.0 CE\python\Lib\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.c<eZdZdZddZejeefdZej fdZ dZ dZ dZ dd Z dd Zd ZejjxZZd ZdZdZejjZeZefdZddZedZdZdZe ddZ!dZ"dZ#dZ$dZ%dS)rz)Dictionary that remembers insertion orderr$c |jnS#t$rFt|_t |jx|_}|x|_|_i|_YnwxYw|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/r0_OrderedDict__map_OrderedDict__update)rotherkwdsroots r__init__zOrderedDict.__init__]s  KKK   #ggDO!'!8!8 8DK$$( (DI DJJJ    e$$t$$$$$s A AAc||vrO|x|j|<}|j}|j}|||c|_|_|_||_|||_||||dS)z!od.__setitem__(i, y) <==> od[i]=yN)r9r5r/r0r)) rr)value dict_setitemrLinklinkr=lasts r __setitem__zOrderedDict.__setitem__jsw d??%)TVV +DJsOd;D9D-14 *DIty$(DId DI T3&&&&&rc||||j|}|j}|j}||_||_d|_d|_dS)z od.__delitem__(y) <==> del od[y]N)r9popr/r0)rr) dict_delitemrC link_prev link_nexts r __delitem__zOrderedDict.__delitem__xsW  T3z~~c""I I " "   rc#ZK|j}|j}||ur|jV|j}||udSdS)zod.__iter__() <==> iter(od)N)r5r0r)rr=currs r__iter__zOrderedDict.__iter__L{y$(NNN9D$rc#ZK|j}|j}||ur|jV|j}||udSdS)z#od.__reversed__() <==> reversed(od)N)r5r/r)rMs rrzOrderedDict.__reversed__rPrc|j}|x|_|_|jt |dS)z.od.clear() -> None. Remove all items from od.N)r5r/r0r9cleardict)rr=s rrSzOrderedDict.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)KeyErrorr5r/r0r)r9rTrG)rrDr=rCrIrJr)r@s 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)r9r/r0r5) rr)rDrCrIrJ 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__r9r7r5)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__markerrTrGr9r/r0rV)rr)defaultmarkerresultrCrIrJs rrGzOrderedDict.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)ros r setdefaultzOrderedDict.setdefaults% $;;9 S rc|s|jjdS|jjdt|dS)zod.__repr__() <==> repr(od)()()) __class__r!listrjrs 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__ isinstancetuplecopyvarsrrGryiterrj)rstateslotsks r __reduce__zOrderedDict.__reduce__s!!##  &%'' $ uuJJLLEJJLLE+--(( # # !T""" !T"""" &u  ~r5$TZZ\\0B0BBBrc,||S)z!od.copy() -> a shallow copy of odryrs rrzOrderedDict.copy#~~d###rc.|}|D]}|||<|S)zYCreate a new ordered dictionary with keys from iterable and values set to value. r$)clsiterabler@rr)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. )r~rrT__eq__allmap_eqrr;s rrzOrderedDict.__eq__0sX e[ ) ) K;;tU++JCT54I4I0J0J J{{4'''rc0|||Sr)updaters r__ior__zOrderedDict.__ior__9s E rct|tstS||}|||Srr~rTNotImplementedryrrr;news r__or__zOrderedDict.__or__=sB%&& "! !nnT"" 5 rct|tstS||}|||Srrrs r__ror__zOrderedDict.__ror__DsB%&& "! !nnU## 4 r)r$)Tr)&r!r"r#__doc__r>rTrEr8r.rKrOrrSrWr[rf_collections_abcMutableMappingrr:rhrjrl__ne__objectrnrGrt_recursive_reprr{rr classmethodrrrrrr$rrrrNs// % % % %"&!1e ' ' ' '-1,<    .2)7>>FX***+++,,, , 3FvxxH',_HHH CCC&$$$[(((rr)r) _tuplegetterc>tt||S)N)doc)property _itemgetter)indexrs rrZsh{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]rwc3 K|] }|dV dS)z=%rNr$).0names r znamedtuple..s(DD$|||DDDDDDrrx namedtuple_) _tuple_new __builtins__r!z lambda _cls, z: _tuple_new(_cls, (z))__new__zCreate new instance of c||}|kr"tddt||S)Nz Expected z arguments, got ) TypeErrorra)rrrq_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: )rrG ValueErrorrz)rr<rq_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)ryr!)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_defaultsrrrr{rr__match_args__zAlias for field number r!__main__)%r~strreplacesplitrzrr_internset enumerate isidentifier _iskeyword startswithaddtyperrrrarTrzipjoinrevalr!r __defaults__r__func__r#r _getframe f_globalsgetr6r")typenamerrrrseenrrfield_defaultsarg_list namespacecoderrrr{rrmethodclass_namespacerrqrrrrrrrrs ` @@@@@@@@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)superr>r)rrr<rys rr>zCounter.__init__Is;  H%%%%%%%rcdS)z1The count of elements not in the Counter is zero.r r$r(s r __missing__zCounter.__missing__Ws qrcDt|S)zSum of the counts)sumrlrs 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))sortedrjrheapqnlargest)rrdrs r most_commonzCounter.most_common`s] 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_repeatrjrs relementszCounter.elementsps'$#HWdjjll$C$CDDDrc td)Nz@Counter.fromkeys() is undefined. Use Counter(iterable) instead.)NotImplementedError)rrvs 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 )r~rMappingrrjrrr)rrr<self_getrcountrys 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])rr~rrrjsubtract)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)ryrTrs rrzCounter.__reduce__s~T },,rcV||vr#t|dSdS)zGLike dict.__delitem__() but does not raise KeyError for missing values.N)rrK)rrrys rrKzCounter.__delitem__s1 4<< GG   % % % % % . =II1qII!47eAh&IIIIIIIrr~rrrrs``rrzCounter.__eq__F%)) "! !IIIIIu IIIIIIrcHt|tstS||k S)z@True if any counts disagree. Missing counts are treated as zero.r~rrrs 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__..rrrrs``r__le__zCounter.__le__rrcRt|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.$rrrrs``r__ge__zCounter.__ge__ rrcRt|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 r~rrrjrr;rqrrnewcounts 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 r.r/s r__sub__zCounter.__sub__?s%)) "! !::<< ( (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 r.rr;rqrr other_countr0s rrzCounter.__or__Rs%)) "! !::<< ( (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 r.r5s r__and__zCounter.__and__fst%)) "! !::<< ( (KD%+K % 3 3uuH!||'t  rclt}|D]\}}|dkr|||<|S)zEAdds an empty counter, effectively stripping negative and zero countsr rrjrrqrrs r__pos__zCounter.__pos__ws>::<< % %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)rj)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}) rjrCrr;rrs 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}) rErFs r__isub__zCounter.__isub__rHrc|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}) rE)rr;rr6rs 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}) rE)rr;rrr6s r__iand__zCounter.__iand__sO ::<< ) )KD%+KU""(T ""$$$rr)#r!r"r#rr>rrrr rrrrrrrKr{rrr$r&r*r,r1r3rr8r<r>rCrGrJrrM __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)rzmaps)rrQs rr>zChainMap.__init__s JJ&2$ rc t|r)rVr(s rrzChainMap.__missing__ssmmrct|jD]} ||cS#t$rYwxYw||Sr)rQrVr)rr)rs r __getitem__zChainMap.__getitem__s\y  G s|###    $$$s  ""Nc||vr||n|Srr$rss rrz ChainMap.gets4KKtCyyW4rcRttj|jSr)rarunionrQrs r__len__zChainMap.__len__s;355; *+++rci}t|jD]/}|t|0t |Sr)rrQrrTrr)rrrs rrOzChainMap.__iter__sL  ** - -G HHT]]7++ , , , ,AwwrcDtfd|jDS)Nc3 K|]}|vV dSrr$)rmr)s rrz(ChainMap.__contains__..s'//3!8//////ranyrQr(s `r __contains__zChainMap.__contains__s(////TY//////rc*t|jSrr]rs r__bool__zChainMap.__bool__49~~rc||jjddtt|jdS)Nrwrrx)ryr!rrreprrQrs rr{zChainMap.__repr__s6.)NNDIIc$ 6J6J,K,KNNNNrc8|tj|g|RS)z?Create a ChainMap with a single dict created from the iterable.)rTr)rrargss 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)ryrQrrs 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. )rryrQ)rr\kwargss r new_childzChainMap.new_childsF 9AA   HHV   t~a,$),,,,rc0|j|jddS)zNew ChainMap from maps[1:].r]N)ryrQrs rparentszChainMap.parentsst~ty}--rc&||jd|<dSNr )rQ)rr)r@s rrEzChainMap.__setitem__s! ! Srcd |jd|=dS#t$rtd|wxYw)Nr $Key not found in the first mapping: )rQrVr(s rrKzChainMap.__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.)rQrWrVrs rrWzChainMap.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 rp)rQrGrV)rr)rfs rrGz ChainMap.pop/s_ K#49Q<#C/$/// / K K KI#IIJJ J Ks8cD|jddS)z'Clear maps[0], leaving maps[1:] intact.r N)rQrSrs rrSzChainMap.clear6s  ! rcF|jd||Srn)rQrrs rrzChainMap.__ior__:s! ! E""" rct|tjstS|}|jd||Srn)r~rrrrrQr)rr;r\s rrzChainMap.__or__>sJ%!1!9:: "! ! IIKK q rct|tjstSt |}t |jD]}||||Sr) r~rrrrTrrQrry)rr;r\childs rrzChainMap.__ror__Ese%!1!9:: "! ! KKdi((  E HHUOOOO~~a   rr)r!r"r#rr>rrTrrXrOr_rarr{rrr__copy__rjrrlrErKrWrGrSrrrr$rrrrs  '''%%%5555,,, 000_OOO33[3CCCH - - - -..X."""KKK BBBKKK!!!!!rrcveZdZddZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZeddZdS)rNc ti|_||||r||dSdSr)datar)rrTris rr>zUserDict.__init__UsK   KK     KK       rc*t|jSrrar{rs rrXzUserDict.__len__\rbrc||jvr |j|St|jdr|j||St |)Nr)r{hasattrryrrVr(s rrTzUserDict.__getitem___sS $)  9S> ! 4>= 1 1 9>--dC88 8smmrc||j|<dSrr{)rr)items rrEzUserDict.__setitem__fs #rc|j|=dSrrr(s rrKzUserDict.__delitem__is IcNNNrc*t|jSr)rr{rs rrOzUserDict.__iter__lDIrc||jvSrrr(s rr_zUserDict.__contains__psdirc*t|jSrrdr{rs rr{zUserDict.__repr__trrct|tr"||j|jzSt|tr||j|zSt Srr~rryr{rTrrs rrzUserDict.__or__ws` 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)r~rr{rs rrzUserDict.__ior__s= eX & &  II #III II II rc|j|j}|j|j|jd|jd<|SNr{)ryrrbrrrinsts rrxzUserDict.__copy__sU~%%dn55 T]+++ $ f 5 : : < < f rc|jtur&t|jSddl}|j} i|_||}||_n #||_wxYw|||Srn)ryrr{rr)rrr{rs rrz UserDict.copys >X % %DINN,,-- - y DI $ADIIDI     s A%% A.c.|}|D]}|||<|Srr$)rrr@rr)s rrzUserDict.fromkeyss, CEE  CAcFFrr)r!r"r#r>rXrTrErKrOr_r{rrrrxrrrr$rrrrRs          [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{rr~rrz)rinitlists rr>zUserList.__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)r~rr{rs r__castzUserList.__casts'x88CuzzeCrc||jvSrrrrs rr_zUserList.__contains__sty  rc*t|jSrr}rs rrXzUserList.__len__rbrct|tr ||j|S|j|Sr)r~sliceryr{ris rrTzUserList.__getitem__s8 a   >>$)A,// /9Q< rc||j|<dSrrrrrs rrEzUserList.__setitem__s ! rc|j|=dSrrrs rrKzUserList.__delitem__s IaLLLrcBt|tr"||j|jzSt|t |jr||j|zS||jt |zSrr~rryr{rrzrs rr1zUserList.__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)r~rr{rrzrs rrGzUserList.__iadd__so eX & & % II #III tDI / / % II III IIe $II rc<||j|zSrryr{rrds r__mul__zUserList.__mul__~~di!m,,,rc&|xj|zc_|Srrrs r__imul__zUserList.__imul__s Q  rc|j|j}|j|j|jddd|jd<|Sr)ryrrbrrs rrxzUserList.__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{rGrs rrGz UserList.popsy}}Qrc:|j|dSr)r{removers rrzUserList.removerrc8|jdSr)r{rSrs rrSzUserList.clears rc,||Srrrs rrz UserList.copys~~d###rc6|j|Sr)r{rrs rrzUserList.countsyt$$$rc(|jj|g|RSrr{r)rrrfs rrzUserList.indexstyt+d++++rc8|jdSr)r{rrs rrzUserList.reverse s rc*|jj|i|dSr)r{sortrrfr<s rrz UserList.sort#s! %%%%%%rct|tr!|j|jdS|j|dSr)r~rr{extendrs rrzUserList.extend&sN eX & & $ I  UZ ( ( ( ( ( I  U # # # # #rrr)#r!r"r#rr>r{r&r$rr,r*rr_rXrTrErKr1rrGr__rmul__rrxrrrGrrSrrrrrrr$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)r~rr{rrseqs rr>zUserString.__init__3sW c3   !DIII Z ( ( ! DIIICDIIIrc*t|jSr)rr{rs r__str__zUserString.__str__;rbrc*t|jSrrrs rr{zUserString.__repr__>rrc*t|jSr)intr{rs r__int__zUserString.__int__Arbrc*t|jSr)floatr{rs r __float__zUserString.__float__DsTYrc*t|jSr)complexr{rs r __complex__zUserString.__complex__Gsty!!!rc*t|jSr)hashr{rs r__hash__zUserString.__hash__Jrrc"|jddfSrrrs rrzUserString.__getnewargs__Ms !!! rcbt|tr|j|jkS|j|kSrr~rr{rstrings rrzUserString.__eq__P0 fj ) ) ,9 + +yF""rcbt|tr|j|jkS|j|kSrrrs rr&zUserString.__lt__U0 fj ) ) +9v{* *y6!!rcbt|tr|j|jkS|j|kSrrrs rr$zUserString.__le__Zrrcbt|tr|j|jkS|j|kSrrrs rr,zUserString.__gt___rrcbt|tr|j|jkS|j|kSrrrs rr*zUserString.__ge__drrcLt|tr|j}||jvSrr)rchars rr_zUserString.__contains__is( dJ ' ' 9Dty  rc*t|jSrr}rs rrXzUserString.__len__nrbrcB||j|Srr)rrs rrTzUserString.__getitem__qs~~di.///rc(t|tr"||j|jzSt|tr||j|zS||jt |zSr)r~rryr{rrs rr1zUserString.__add__tsy eZ ( ( 5>>$)ej"899 9 s # # 5>>$)e"344 4~~di#e**4555rct|tr|||jzS|t||jzSr)r~rryr{rs rrzUserString.__radd__{sL eS ! ! 5>>%$)"344 4~~c%jj494555rc<||j|zSrrrs rrzUserString.__mul__rrc<||j|zSrrrrfs r__mod__zUserString.__mod__s~~di$.///rcL|t||zSr)ryr)rtemplates r__rmod__zUserString.__rmod__s~~c(mmd2333rcZ||jSr)ryr{ capitalizers rrzUserString.capitalizes"~~di2244555rcZ||jSr)ryr{casefoldrs rrzUserString.casefold"~~di0022333rcN||jj|g|RSr)ryr{centerrwidthrfs rrzUserString.centers,~~.di.uzUserString.ljust*~~odioe;d;;;<<rr{rrrrrrr&r$r,r*r_rXrTr1rrrrrrrrr_maxsizerr rrrrrrr!rr$r'r)r+r.rr1r3r5r7r9r;rr>rArDr maketransrIrrPrRrTrVrXrr\r^rrbrergrirkrmr$rrrr1s!!!   """### """ ### """ ### !!! 000666666 ---H000444666444>>> !dl0000 >>> >>> 2222 &'DL6666==== T\//// ///--- !dl0000#########%%%###(((###%%%'''############===1117777 I(((EEEE !dl0000 !"t|1111===)))7777....////....()dl88886666444111:::11166666rr)4r__all__rsysr_ itertoolsr rr rrrkeywordrroperatorrrrrreprlibrr_weakrefrr8 _collectionsr MutableSequenceregister ImportErrorrKeysViewr ItemsViewr& ValuesViewr+rr.rTrrr 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