%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/opt/alt/python27/lib/python2.7/site-packages/tempita/
Upload File :
Create Path :
Current File : //proc/self/root/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pyc

�
V��Lc@sqdZddlZddlmZdgZdefd��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

i����N(tbasestring_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((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pyt__init__&scCs
t|j�S(N(tlooper_iterR(R((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pyt__iter__)scCsd|jj|jfS(Ns<%s for %r>(t	__class__t__name__R(R((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pyt__repr__,s(Rt
__module__t__doc__RRR	(((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pyRs			RcBs;eZd�Zd�Zd�Zejdkr9eZnRS(cCst|�|_d|_dS(Ni(tlistRtpos(RR((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pyR3scCs|S(N((R((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pyR7scCsY|jt|j�kr!t�nt|j|j�|j|jf}|jd7_|S(Ni(R
tlenRt
StopIterationtloop_pos(Rtresult((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pyt__next__:s
	%t3(RR
RRRtsystversiontnext(((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pyR1s
			RcBs%eZd�Zd�Zd�Zee�Zd�Zee�Zd�Zee�Zd�Zee�Ze	j
dkr�eZnd�Zee�Zd�Z
ee
�Z
d	�Zee�Zd
�Zee�Zd�Zee�Zd�Zee�Zdd
�Zdd�Zd�ZRS(cCs||_||_dS(N(RR
(RRR
((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pyRGs	cCsd|j|j|jfS(Ns<loop pos=%r at %r>(RR
(R((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pyR	KscCs|jS(N(R
(R((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pytindexOscCs|jdS(Ni(R
(R((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pytnumberSscCs|j|jS(N(RR
(R((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pytitemWscCs/y|j|jdSWntk
r*dSXdS(Ni(RR
t
IndexErrortNone(R((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pyR[s
RcCs%|jdkrdS|j|jdS(Nii(R
RR(R((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pytpreviousescCs|jdS(Ni(R
(R((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pytoddkscCs|jdS(Ni(R
(R((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pytevenoscCs
|jdkS(Ni(R
(R((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pytfirstsscCs|jt|j�dkS(Ni(R
RR(R((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pytlastwscCs
t|j�S(N(RR(R((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pytlength{scCs&|jr
tS|j|j|j|�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((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pytfirst_groups	cCs&|jr
tS|j|j|j|�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.
        (R R"R#RR(RR$((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pyt
last_group�s	cCs�|dkr||kSt|t�r�|jd�r�|d}|jd�ry|d }t||��t||��kSt||�t||�kSn7t|d�r�||�||�kS||||kSdS(Nt.is()i����t__call__(Rt
isinstanceRt
startswithtendswithtgetattrthasattr(RRtotherR$((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pyR#�s


"N(RR
RR	RtpropertyRRRRRRRRRRR R!RR%R&R#(((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pyREs6													(	RRttempita.compat3Rt__all__tobjectRRR(((s@/opt/alt/python27/lib/python2.7/site-packages/tempita/_looper.pyt<module>s	

Zerion Mini Shell 1.0