Ñò ô†³Kc@sUdZdgZdefd„ƒYZdefd„ƒYZdefd„ƒYZdS(s Helper for looping over sequences, particular in templates. Often in a loop in a template it's handy to know what's next up, previously up, if this is the first or last item in the sequence, etc. These can be awkward to manage in a normal Python loop, but using the looper you can get a better sense of the context. Use like:: >>> for loop, item in looper(['a', 'b', 'c']): ... print loop.number, item ... if not loop.last: ... print '---' 1 a --- 2 b --- 3 c tloopercBs)eZdZd„Zd„Zd„ZRS(sĴ Helper for looping (particularly in templates) Use this like:: for loop, item in looper(seq): if loop.first: ... cCs ||_dS(N(tseq(tselfR((s5/usr/lib/python2.6/site-packages/paste/util/looper.pyt__init__"scCs t|iƒS(N(t looper_iterR(R((s5/usr/lib/python2.6/site-packages/paste/util/looper.pyt__iter__%scCsd|ii|ifS(Ns <%s for %r>(t __class__t__name__R(R((s5/usr/lib/python2.6/site-packages/paste/util/looper.pyt__repr__(s(Rt __module__t__doc__RRR(((s5/usr/lib/python2.6/site-packages/paste/util/looper.pyRs   RcBs#eZd„Zd„Zd„ZRS(cCst|ƒ|_d|_dS(Ni(tlistRtpos(RR((s5/usr/lib/python2.6/site-packages/paste/util/looper.pyR.scCs|S(N((R((s5/usr/lib/python2.6/site-packages/paste/util/looper.pyR2scCs[|it|iƒjo t‚nt|i|iƒ|i|if}|id7_|S(Ni(R tlenRt StopIterationtloop_pos(Rtresult((s5/usr/lib/python2.6/site-packages/paste/util/looper.pytnext5s  %(RR RRR(((s5/usr/lib/python2.6/site-packages/paste/util/looper.pyR,s  RcBs eZd„Zd„Zd„ZeeƒZd„ZeeƒZd„ZeeƒZd„ZeeƒZd„Z ee ƒZ d„Z ee ƒZ d„Z ee ƒZ d „Z ee ƒZ d „Z ee ƒZ d „ZeeƒZdd „Zdd „Zd„ZRS(cCs||_||_dS(N(RR (RRR ((s5/usr/lib/python2.6/site-packages/paste/util/looper.pyR>s cCsd|ittfS(Ns(RR (R((s5/usr/lib/python2.6/site-packages/paste/util/looper.pyRBscCs|iS(N(R (R((s5/usr/lib/python2.6/site-packages/paste/util/looper.pytindexFscCs |idS(Ni(R (R((s5/usr/lib/python2.6/site-packages/paste/util/looper.pytnumberJscCs|i|iS(N(RR (R((s5/usr/lib/python2.6/site-packages/paste/util/looper.pytitemNscCs1y|i|idSWntj odSXdS(Ni(RR t IndexErrortNone(R((s5/usr/lib/python2.6/site-packages/paste/util/looper.pyRRscCs'|idjodS|i|idS(Nii(R RR(R((s5/usr/lib/python2.6/site-packages/paste/util/looper.pytpreviousYscCs |id S(Ni(R (R((s5/usr/lib/python2.6/site-packages/paste/util/looper.pytodd_scCs |idS(Ni(R (R((s5/usr/lib/python2.6/site-packages/paste/util/looper.pytevencscCs |idjS(Ni(R (R((s5/usr/lib/python2.6/site-packages/paste/util/looper.pytfirstgscCs|it|iƒdjS(Ni(R R R(R((s5/usr/lib/python2.6/site-packages/paste/util/looper.pytlastkscCs t|iƒS(N(R R(R((s5/usr/lib/python2.6/site-packages/paste/util/looper.pytlengthoscCs(|iotS|i|i|i|ƒS(s Returns true if this item is the start of a new group, where groups mean that some attribute has changed. The getter can be None (the item itself changes), an attribute name like ``'.attr'``, a function, or a dict key or list index. (RtTruet_compare_groupRR(Rtgetter((s5/usr/lib/python2.6/site-packages/paste/util/looper.pyt first_groupss cCs(|iotS|i|i|i|ƒS(s Returns true if this item is the end of a new group, where groups mean that some attribute has changed. The getter can be None (the item itself changes), an attribute name like ``'.attr'``, a function, or a dict key or list index. (RRRRR(RR((s5/usr/lib/python2.6/site-packages/paste/util/looper.pyt last_group~s cCsÙ|djo ||jSt|tƒow|idƒog|d}|idƒo-|d }t||ƒƒt||ƒƒjSt||ƒt||ƒjSn7t|ƒo||ƒ||ƒjS||||jSdS(Nt.is()iŝ˙˙˙(Rt isinstancet basestringt startswithtendswithtgetattrtcallable(RRtotherR((s5/usr/lib/python2.6/site-packages/paste/util/looper.pyR‰s    #  N(RR RRRtpropertyRRRRRRRRRRR R!R(((s5/usr/lib/python2.6/site-packages/paste/util/looper.pyR<s2                       N(R t__all__tobjectRRR(((s5/usr/lib/python2.6/site-packages/paste/util/looper.pyts