!9QRc@s<dddddgZddlTddlZeej7ZddlmZmZdd lmZdd lm Z ddl Z ddl Zdd lmZmZmZydd lmZWn!ek rdd lmZnXdefd YZeedZdefdYZe dkr8ddl!m"Z"m#Z#edde$Z%e%ddddZ&deddfdYZ%x/e%dde%dddfD] Z&e&GHqWdeddfdYZ%e%d d!j'dd"GHed#e%j(d$fZ)e)j*GHddl+Z+ed%d&Z,e,e+j-GHndS('tCountertdequet defaultdictt namedtuplet OrderedDicti(t*N(RR(t itemgetter(t iskeyword(trepeattchaintstarmap(t get_identcBs+eZdZdZddejdZddejdZdZdZdZ d Z d Z d Z d Z d ZdZejZeZeZedZddZedZidZdZdZeddZdZdZ dZ!dZ"dZ#RS(s)Dictionary that remembers insertion ordercOst|dkr+tdt|ny |jWn7tk rog|_}||dg|(i|_nX|j||dS(sInitialize an ordered dictionary. The signature is the same as regular dictionaries, but keyword arguments are not recommended because their insertion order is arbitrary. is$expected at most 1 arguments, got %dN(tlent TypeErrort_OrderedDict__roottAttributeErrortNonet_OrderedDict__mapt_OrderedDict__update(tselftargstkwdstroot((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt__init__%s    iicCs\||krH|j}||}|||g||<||<|j| od[i]=yN(RR(RtkeytvaluetPREVtNEXTt dict_setitemRtlast((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt __setitem__5s    )cCs@||||jj|\}}}|||<||| del od[y]N(Rtpop(RRRRt dict_delitemt link_prevt link_next((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt __delitem__?s  ccsId\}}|j}||}x#||k rD||V||}q"WdS(sod.__iter__() <==> iter(od)iiN(ii(R(RRtKEYRtcurr((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt__iter__Hs     ccsId\}}|j}||}x#||k rD||V||}q"WdS(s#od.__reversed__() <==> reversed(od)iiN(ii(R(RRR$RR%((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt __reversed__Rs     cCsUx|jjD] }|2qW|j}||dg|(|jjtj|dS(s.od.clear() -> None. Remove all items from od.N(Rt itervaluesRRtcleartdict(RtnodeR((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyR)\s   cCs t|S(sod.keys() -> list of keys in od(tlist(R((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pytkeysgscCsg|D]}||^qS(s#od.values() -> list of values in od((RR((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pytvalueskscCs!g|D]}|||f^qS(s.od.items() -> list of (key, value) pairs in od((RR((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pytitemsoscCs t|S(s0od.iterkeys() -> an iterator over the keys in od(titer(R((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pytiterkeysssccsx|D]}||VqWdS(s2od.itervalues -> an iterator over the values in odN((Rtk((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyR(ws ccs$x|D]}|||fVqWdS(s=od.iteritems -> an iterator over the (key, value) pairs in odN((RR2((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt iteritems|s cCsC||kr!||}||=|S||jkr?t|n|S(sod.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. (t_OrderedDict__markertKeyError(RRtdefaulttresult((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyRs  cCs"||kr||S|||<|S(sDod.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od((RRR6((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt setdefaults  cCsR|stdnt|r*t|n t|}|j|}||fS(sod.popitem() -> (k, v), return and remove a (key, value) pair. Pairs are returned in LIFO order if last is true or FIFO order if false. sdictionary is empty(R5tnexttreversedR0R(RRRR((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pytpopitems $cCsst|tf}||kr%dSd|| repr(od)s...is%s()s%s(%r)N(tidt _get_identt __class__t__name__R/(Rt _repr_runningtcall_key((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt__repr__s  cCsg|D]}|||g^q}t|j}x'ttD]}|j|dqEW|rx|j|f|fS|j|ffS(s%Return state information for picklingN(tvarstcopyRRRR>(RR2R/t inst_dict((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt __reduce__s#cCs |j|S(s!od.copy() -> a shallow copy of od(R>(R((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyRDscCs(|}x|D]}||| New ordered dictionary with keys from S. If not specified, the value defaults to None. ((tclstiterableRRR((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pytfromkeyss  cCsMt|tr=t|t|ko<|j|jkStj||S(sod.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive while comparison to a regular mapping is order-insensitive. (t isinstanceRR R/R*t__eq__(Rtother((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyRKs.cCs ||k S(sod.__ne__(y) <==> od!=y((RRL((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt__ne__scCs t|S(s@od.viewkeys() -> a set-like object providing a view on od's keys(tKeysView(R((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pytviewkeysscCs t|S(s<od.viewvalues() -> an object providing a view on od's values(t ValuesView(R((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt viewvaluesscCs t|S(sBod.viewitems() -> a set-like object providing a view on od's items(t ItemsView(R((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt viewitemssN($R?t __module__t__doc__RR*RR#R&R'R)R-R.R/R1R(R3tMutableMappingtupdateRtobjectR4RRR8tTrueR;RBRFRDt classmethodRIRKRMRORQRS(((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyRs:                c Bs/e|er*|jddj}neee|}|re|}e}xe |D]\}}e d|D se |s| s|dj s|j ds||krd|||Returns 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 accessable 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) t,t css'|]}|jp|dkVqdS(t_N(tisalnum(t.0tc((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pys siR]s_%dcss'|]}|jp|dkVqdS(R]N(R^(R_R`((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pys ssWType names and field names can only contain alphanumeric characters and underscores: %rs2Type names and field names cannot be a keyword: %rs9Type names and field names cannot start with a number: %rs/Field names cannot start with an underscore: %rs$Encountered duplicate field name: %rt'tiis, css|]}d|VqdS(s%s=%%rN((R_tname((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pys &ssclass %(typename)s(tuple): '%(typename)s(%(argtxt)s)' __slots__ = () _fields = %(field_names)r def __new__(_cls, %(argtxt)s): 'Create new instance of %(typename)s(%(argtxt)s)' return _tuple.__new__(_cls, (%(argtxt)s)) @classmethod def _make(cls, iterable, new=tuple.__new__, len=len): 'Make a new %(typename)s object from a sequence or iterable' result = new(cls, iterable) if len(result) != %(numfields)d: raise TypeError('Expected %(numfields)d arguments, got %%d' %% len(result)) return result def __repr__(self): 'Return a nicely formatted representation string' return '%(typename)s(%(reprtxt)s)' %% self def _asdict(self): 'Return a new OrderedDict which maps field names to their values' return OrderedDict(zip(self._fields, self)) __dict__ = property(_asdict) def _replace(_self, **kwds): 'Return a new %(typename)s object replacing specified fields with new values' result = _self._make(map(kwds.pop, %(field_names)r, _self)) if kwds: raise ValueError('Got unexpected field names: %%r' %% kwds.keys()) return result def __getnewargs__(self): 'Return self as a plain tuple. Used by copy and pickle.' return tuple(self) sI %s = _property(_itemgetter(%d), doc='Alias for field number %d') t _itemgetterR?s namedtuple_%sRt _propertyt_tuples: t__main__( RJt basestringtreplacetsplitttupletmaptstrR,tsett enumeratetallt _iskeywordtisdigitt startswithtaddt ValueErrorR treprtjointlocalsR*RdRtpropertyt SyntaxErrortmessaget_syst _getframet f_globalstgetRTR(ttypenamet field_namestverbosetrenametnamestseentiRct seen_namest numfieldstargtxttreprtxtttemplatet namespaceteR7((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyRs^  #&         %cBseZdZddZdZddZdZeddZ ddZ ddZ dZ d Z d Zd Zd Zd ZdZdZRS(sDict 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)] cKs'tt|j|j||dS(s 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(tsuperRRRW(RRHR((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyRs cCsdS(s1The count of elements not in the Counter is zero.i((RR((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt __missing__scCsP|dkr.t|jdtddtStj||jdtdS(sList 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('abcdeabcdabcaba').most_common(3) [('a', 5), ('b', 4), ('c', 3)] RitreverseN(RtsortedR3RdRYt_heapqtnlargest(Rtn((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt most_commons "cCstjtt|jS(sIterator 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. (t_chaint from_iterablet_starmapt_repeatR3(R((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pytelementsscCstddS(Ns@Counter.fromkeys() is undefined. Use Counter(iterable) instead.(tNotImplementedError(RGRHtv((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyRIscKs|dk rt|trz|ra|j}xJ|jD]#\}}||d|||>> 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 iiN(RRJtMappingRR3RRRW(RRHRtself_gettelemtcount((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyRWs    cKs|dk r|j}t|tr[x\|jD]#\}}||d|||>> 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 iiN(RRRJRR/tsubtract(RRHRRRR((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyRs   cCs |j|S(sReturn a shallow copy.(R>(R((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyRDscCs|jt|ffS(N(R>R*(R((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyRFscCs)||kr%tt|j|ndS(sGLike dict.__delitem__() but does not raise KeyError for missing values.N(RRR#(RR((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyR#s cCsI|sd|jjSdjtdj|j}d|jj|fS(Ns%s()s, s%r: %rs%s({%s})(R>R?RwRlt__mod__R(RR/((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyRB s!cCst|tstSt}xA|jD]3\}}|||}|dkr)|||>> Counter('abbb') + Counter('bcc') Counter({'b': 4, 'c': 2, 'a': 1}) i(RJRtNotImplementedR/(RRLR7RRtnewcount((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt__add__/s  cCst|tstSt}xA|jD]3\}}|||}|dkr)|||>> Counter('abbbc') - Counter('bccd') Counter({'b': 2, 'a': 1}) i(RJRRR/(RRLR7RRR((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt__sub__Bs  cCst|tstSt}xU|jD]G\}}||}||krQ|n|}|dkr)|||>> Counter('abbb') | Counter('bcc') Counter({'b': 3, 'c': 2, 'a': 1}) i(RJRRR/(RRLR7RRt other_countR((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt__or__Us   cCsxt|tstSt}xU|jD]G\}}||}||krQ|n|}|dkr)|||>> Counter('abbb') & Counter('bcc') Counter({'b': 1}) i(RJRRR/(RRLR7RRRR((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt__and__is   N(R?RTRURRRRRRZRIRWRRDRFR#RBRRRR(((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyRds"+    #        Rg(tloadstdumpstPointsx, ytxi tyisx ycBs&eZdZedZdZRS(cCs|jd|jddS(Nig?(RR(R((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pythypotscCsd|j|j|jfS(Ns$Point: x=%6.3f y=%6.3f hypot=%6.3f(RRR(R((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt__str__s((R?RTt __slots__RyRR(((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyRsiiiig@cBs/eZdZdZeejZedZ RS(sHPoint class with optimized _make() and _replace() without error-checkingcKs|j||jd|S(NRR(RR(t_makeR(Rt_mapR((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyt_replaces(( R?RTRURRZRkt__new__RRlR(((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyRsi iidtPoint3Dtzt TestResultssfailed attempted(.t__all__t_abcollt _collectionsRRtoperatorRRdtkeywordRRqtsysR|theapqRt itertoolsRRR RR RtthreadR R=t ImportErrort dummy_threadR*RtFalseRRR?tcPickleRRRYRtpRt_fieldsRRUtdoctestRttestmod(((sL/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/collections.pyts>      w )