ok

Mini Shell

Direktori : /proc/self/root/lib/python2.7/site-packages/jinja2/
Upload File :
Current File : //proc/self/root/lib/python2.7/site-packages/jinja2/runtime.pyc

�
��Rc
@sKdZddlmZddlmZmZddlmZmZm	Z	m
Z
mZmZm
Z
ddlmZmZmZddlmZmZmZmZmZmZmZmZddd	d
ddd
ddddddg
ZeZd�Ze�Zd�Z d�Z!d(d(d(d(d�Z#defd��YZ$defd��YZ%y!ddl&m'Z'e'j(e%�Wne)k
r�nXdefd��YZ*defd��YZ+edefd ��Y�Z,d	efd!��YZ-ed"efd#��Y�Z.ed$e.fd%��Y�Z/ed&e.fd'��Y�Z0e.`1e/`1e0`1d(S()s}
    jinja2.runtime
    ~~~~~~~~~~~~~~

    Runtime helpers.

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD.
i����(tchain(tEvalContextt_context_function_types(tMarkuptsoft_unicodetescapetmissingtconcattinternalcodetobject_type_repr(tUndefinedErrortTemplateRuntimeErrortTemplateNotFound(tnexttimapt	text_typet	iteritemstimplements_iteratortimplements_to_stringtstring_typestPY2tLoopContexttTemplateReferencetMacroRRRRRtmarkup_jointunicode_joint	to_stringtidentityRcCs|S(N((tx((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt<lambda> scCshg}tt|�}xF|D]>}|j|�t|d�rtd�jt||��SqWt|�S(s@Concatenation that escapes if necessary and converts to unicode.t__html__u(RRtappendthasattrRtjoinRR(tseqtbuftiteratortarg((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR%s

 cCsttt|��S(s4Simple args to unicode conversion and concatenation.(RRR(R"((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR0sc
Cs�|dkri}n|r$|}nt|p0d|�}|r�|rTt|�}nxJt|�D]9\}}	|d dkra|	tk	ra|	||d<qaqaWnt||||�S(s(Internal helper to for context creation.itl_N((tNonetdictRRtContext(
tenvironmentt
template_nametblockstvarstsharedtglobalstlocalstparenttkeytvalue((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pytnew_context5s		cBs)eZdZd�Zd�Zd�ZRS(sThe `self` in templates.cCs
||_dS(N(t_TemplateReference__context(tselftcontext((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt__init__LscCs&|jj|}t||j|d�S(Ni(R5R,tBlockReference(R6tnameR,((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt__getitem__OscCsd|jj|jjfS(Ns<%s %r>(t	__class__t__name__R5R:(R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt__repr__Ss	(R=t
__module__t__doc__R8R;R>(((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyRIs		R)cBs�eZdZdZd	�Zd
�Zdd�Zd�Zd
�Z	d�Z
ed��Zdd�Z
d�Zed�Zed�Zed�Zer�ed�Zed�Zed�Zn[d�Zd�Zd�ZRS(s�The template context holds the variables of a template.  It stores the
    values passed to the template and also the names the template exports.
    Creating instances is neither supported nor useful as it's created
    automatically at various stages of the template evaluation and should not
    be created by hand.

    The context is immutable.  Modifications on :attr:`parent` **must not**
    happen and modifications on :attr:`vars` are allowed from generated
    template code only.  Template filters and global functions marked as
    :func:`contextfunction`\s get the active context passed as first argument
    and are allowed to access the context read-only.

    The template context supports read only dict operations (`get`,
    `keys`, `values`, `items`, `iterkeys`, `itervalues`, `iteritems`,
    `__getitem__`, `__contains__`).  Additionally there is a :meth:`resolve`
    method that doesn't fail with a `KeyError` but returns an
    :class:`Undefined` object for missing variables.
    R1R-R*teval_ctxt
exported_varsR:R,t__weakref__cCsh||_i|_||_t|j|�|_t�|_||_td�t	|�D��|_
dS(Ncss$|]\}}||gfVqdS(N((t.0tktv((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pys	<genexpr>{s(R1R-R*RRAtsetRBR:R(RR,(R6R*R1R:R,((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR8ps				cCsjy,|j|}|j|�d}||Wn(tk
rV|jjd|dd�SXt||||�S(sRender a parent block.is#there is no parent block called %r.R:tsuper(R,tindextLookupErrorR*t	undefinedR9(R6R:tcurrentR,RI((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyRH}s

cCs%y||SWntk
r |SXdS(sfReturns an item from the template context, if it doesn't exist
        `default` is returned.
        N(tKeyError(R6R2tdefault((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pytget�s
cCsG||jkr|j|S||jkr4|j|S|jjd|�S(s�Looks up a variable like `__getitem__` or `get` but returns an
        :class:`Undefined` object with the name of the name looked up.
        R:(R-R1R*RK(R6R2((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pytresolve�s
cst�fd��jD��S(s+Get a new dict with the exported variables.c3s"|]}|�j|fVqdS(N(R-(RDRE(R6(s2/usr/lib/python2.7/site-packages/jinja2/runtime.pys	<genexpr>�s(R(RB(R6((R6s2/usr/lib/python2.7/site-packages/jinja2/runtime.pytget_exported�scCst|j|j�S(s`Return a copy of the complete context as dict including the
        exported variables.
        (R(R1R-(R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pytget_all�scOs�t}|j}x'dD]}t||�r|}PqqWt|t�r�t|dd�rj|f|}q�t|dd�r�|jf|}q�t|dd�r�|jf|}q�ny|||�SWntk
r�|jj	d�SXdS(s�Call the callable with the arguments and keyword arguments
        provided but inject the active context or environment as first
        argument if the callable is a :func:`contextfunction` or
        :func:`environmentfunction`.
        tcontextfunctiontevalcontextfunctiontenvironmentfunctionisGvalue was undefined because a callable raised a StopIteration exceptionN(RSRTRU(
tTruet__call__R t
isinstanceRtgetattrRAR*t
StopIterationRK(t_Context__selft
_Context__objtargstkwargst__traceback_hide__tfntfn_type((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pytcall�s&	

cCsmt|j|ji|jtd|�}|jj|j�|j|_|j	jd�t
|j	�D��|S(s5Internal helper function to create a derived context.css'|]\}}|t|�fVqdS(N(tlist(RDRERF((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pys	<genexpr>�sN(R4R*R:R1RVR'R-tupdateRAR,R(R6R0R7((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pytderived�s#cs1�fd�}tt��j|_�|_|S(Ncst|j����S(N(RYRR(R6(tmeth(s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR�s(RYR(R@R=(Rftproxy((Rfs2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt_all�s	tkeystvaluestitemstiterkeyst
itervaluesRcCs||jkp||jkS(N(R-R1(R6R:((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt__contains__�scCs1|j|�}t|t�r-t|��n|S(sTLookup a variable or raise `KeyError` if the variable is
        undefined.
        (RPRXt	UndefinedRM(R6R2titem((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR;�scCs&d|jjt|j��|jfS(Ns
<%s %s of %r>(R<R=treprRRR:(R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR>�s	(sparentsvarssenvironmentseval_ctxs
exported_varssnamesblockss__weakref__N(R=R?R@t	__slots__R8RHR'RORPRQRRRRbReRhRiRjRkRRlRmRRnR;R>(((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR)Zs.	
			
		!					(tMappingR9cBs5eZdZd�Zed��Zed��ZRS(s"One block on a template reference.cCs(||_||_||_||_dS(N(R:t_contextt_stackt_depth(R6R:R7tstacktdepth((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR8s			cCs_|jdt|j�kr<|jjjd|jdd�St|j|j|j|jd�S(sSuper the block.is#there is no parent block called %r.R:RH(RvtlenRuRtR*RKR:R9(R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyRHscCsAt|j|j|j��}|jjjr=t|�}n|S(N(RRuRvRtRAt
autoescapeR(R6trv((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyRWs(R=R?R@R8tpropertyRHRRW(((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR9�s	
cBs�eZdZddd�Zd�Zed��Zed��Zed��Z	ed��Z
ed��Zed	��Zd
�Z
d�Zd�Zed
��ZeZ[ed��Zd�ZRS(s%A loop context for dynamic iteration.icCsst|�|_||_|j�|_d|_||_yt|�|_Wn t	t
fk
rnd|_nXdS(Ni����(titert	_iteratort_recurset
_safe_nextt_aftertindex0tdepth0Ryt_lengtht	TypeErrortAttributeErrorR'(R6titerabletrecurseR�((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR8s			cGs*|std��n||jt|�S(s7Cycles among the arguments with the current loop index.sno items for cycling given(R�R�Ry(R6R]((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pytcycle+scCs
|jdkS(Ni(R�(R((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR1scCs
|jtkS(N(R�t_last_iteration(R((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR2scCs|jdS(Ni(R�(R((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR3scCs|j|jS(N(tlengthR�(R((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR4scCs|j|jS(N(R�RI(R((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR5scCs|jdS(Ni(R�(R((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR6scCs|jS(N(R�(R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt__len__8scCs
t|�S(N(tLoopContextIterator(R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt__iter__;scCs*yt|j�SWntk
r%tSXdS(N(R
R~RZR�(R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR�>s
cCs;|jdkrtd��n|j||j|jd�S(NsMTried to call non recursive loop.  Maybe you forgot the 'recursive' modifier.i(RR'R�R�(R6R�((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pytloopDscCsQ|jdkrJt|j�}t|�|_t|�|jd|_n|jS(Ni(R�R'ttupleR~R}RyR�(R6R�((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR�Ps
cCsd|jj|j|jfS(Ns
<%s %r/%r>(R<R=RIR�(R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR>\s	N(R=R?R@R'R8R�R|tfirsttlastRItrevindext	revindex0RxR�R�R�RR�RWR�R>(((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyRs"					R�cBs/eZdZdZd�Zd�Zd�ZRS(s The iterator for a loop context.R7cCs
||_dS(N(R7(R6R7((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR8iscCs|S(N((R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR�lscCsU|j}|jd7_|jtkr3t��n|j}|j�|_||fS(Ni(R7R�R�R�RZR�(R6tctxt	next_elem((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt__next__os		(scontext(R=R?R@RrR8R�R�(((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR�ds
		cBs/eZdZd�Zed��Zd�ZRS(sWraps a macro function.c		Cs[||_||_t|�|_||_||_||_||_||_||_	dS(N(
t_environmentt_funcRyt_argument_countR:t	argumentstdefaultstcatch_kwargst
catch_varargstcaller(	R6R*tfuncR:R�R�R�R�R�((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR8|s							c	Os�t||j �}t|�}||jkr�x�t|jt|��D]�\}}y|j|�}Wn]tk
r�y|j||j|}Wq�tk
r�|j	j
d|d|�}q�XnX|j|�qHWn|jr-|jdd�}|dkr|j	j
ddd�}n|j|�n|jrF|j|�n.|rttd|jtt|��f��n|jr�|j||j�n:t|�|jkr�td|jt|j�f��n|j|�S(Nsparameter %r was not providedR:R�sNo caller defineds%macro %r takes no keyword argument %rs+macro %r takes not more than %d argument(s)(RcR�Ryt	enumerateR�tpopRMR�t
IndexErrorR�RKRR�R'R�R�R:R
R}R�R�(	R6R]R^R�tofftidxR:R3R�((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyRW�s<&

			"	cCs2d|jj|jdkr!dp-t|j�fS(Ns<%s %s>t	anonymous(R<R=R:R'Rq(R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR>�s	(R=R?R@R8RRWR>(((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyRys	*RocBs�eZdZdZdeded�Zed��Z	ed��Z
e	ZZZ
ZZZZZZZZZZZZZZZZZZZ Z!Z"Z#d�Z$d	�Z%d
�Z&d�Z'd�Z(d
�Z)d�Z*d�Z+RS(sVThe default undefined type.  This undefined type can be printed and
    iterated over, but every other access will raise an :exc:`UndefinedError`:

    >>> foo = Undefined(name='foo')
    >>> str(foo)
    ''
    >>> not foo
    True
    >>> foo + 42
    Traceback (most recent call last):
      ...
    UndefinedError: 'foo' is undefined
    t_undefined_hintt_undefined_objt_undefined_namet_undefined_exceptioncCs(||_||_||_||_dS(N(R�R�R�R�(R6thinttobjR:texc((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR8�s			cOs�|jdkr~|jtkr.d|j}q�t|jt�s_dt|j�|jf}q�dt|j�|jf}n	|j}|j|��dS(siRegular callback function for undefined objects that raises an
        `UndefinedError` on call.
        s%r is undefineds%s has no element %rs%r has no attribute %rN(	R�R'R�RR�RXRR	R�(R6R]R^R�((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt_fail_with_undefined_error�s	cCs)|d dkrt|��n|j�S(Nit__(R�R�(R6R:((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt__getattr__�scCst|�t|�kS(N(ttype(R6tother((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt__eq__�scCs|j|�S(N(R�(R6R�((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt__ne__�scCstt|��S(N(tidR�(R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt__hash__�scCsdS(Nu((R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt__str__�scCsdS(Ni((R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR�sccsdS(N((R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR�scCstS(N(tFalse(R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt__nonzero__scCsdS(NRo((R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR>
s(s_undefined_hints_undefined_objs_undefined_names_undefined_exceptionN(,R=R?R@RrR'RR
R8RR�R�t__add__t__radd__t__mul__t__rmul__t__div__t__rdiv__t__truediv__t__rtruediv__t__floordiv__t
__rfloordiv__t__mod__t__rmod__t__pos__t__neg__RWR;t__lt__t__le__t__gt__t__ge__t__int__t	__float__t__complex__t__pow__t__rpow__R�R�R�R�R�R�R�R>(((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyRo�sf							tDebugUndefinedcBseZdZdZd�ZRS(sAn undefined that returns the debug info when printed.

    >>> foo = DebugUndefined(name='foo')
    >>> str(foo)
    '{{ foo }}'
    >>> not foo
    True
    >>> foo + 42
    Traceback (most recent call last):
      ...
    UndefinedError: 'foo' is undefined
    cCsN|jdkrC|jtkr)d|jSdt|j�|jfSd|jS(Nu{{ %s }}s{{ no such element: %s[%r] }}u!{{ undefined value printed: %s }}(R�R'R�RR�R	(R6((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR�s((R=R?R@RrR�(((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR�s
tStrictUndefinedcBs9eZdZdZejZZZZ	Z
ZZZ
RS(s=An undefined that barks on print and iteration as well as boolean
    tests and all kinds of comparisons.  In other words: you can do nothing
    with it except checking if it's defined using the `defined` test.

    >>> foo = StrictUndefined(name='foo')
    >>> str(foo)
    Traceback (most recent call last):
      ...
    UndefinedError: 'foo' is undefined
    >>> not foo
    Traceback (most recent call last):
      ...
    UndefinedError: 'foo' is undefined
    >>> foo + 42
    Traceback (most recent call last):
      ...
    UndefinedError: 'foo' is undefined
    ((R=R?R@RrRoR�R�R�R�R�R�R�t__bool__R�(((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyR�)sN(2R@t	itertoolsRtjinja2.nodesRRtjinja2.utilsRRRRRRR	tjinja2.exceptionsR
RRtjinja2._compatR
RRRRRRRt__all__RRtobjectR�RRR'R4RR)tcollectionsRstregistertImportErrorR9RR�RRoR�R�Rr(((s2/usr/lib/python2.7/site-packages/jinja2/runtime.pyt<module>
sF4:					�
L@T

Zerion Mini Shell 1.0