%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/opt/alt/python27/lib/python2.7/site-packages/jinja2/
Upload File :
Create Path :
Current File : //proc/self/root/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pyo

�
��Rc@s�dZddlZddlmZddlmZddlmZmZm	Z	m
Z
mZmZm
Z
mZdZeddd	d
dg�Zedd
dg�Zeddg�Zes�e�ZnddlZejddedd�ddlmZefZefZefZyGddlmZmZddl m Z eeef7Zee f7ZWne!k
rpnXy!ddl"m#Z#ee#f7ZWne!k
r�nXyGddlm$Z$m%Z%m&Z&ee$f7Zee%f7Zee&f7ZWne!k
rnXee'ddddddd d!g�fee'ddd"d#d!g�fee'd$d%d&d'd(dg�fee'd$d)dd(d*dd+dd,g	�ffZ(d-�Z)d.�Z*d/�Z+d0�Z,d1efd2��YZ-d3e-fd4��YZ.dS(5sj
    jinja2.sandbox
    ~~~~~~~~~~~~~~

    Adds a sandbox layer to Jinja as it was the default behavior in the old
    Jinja 1 releases.  This sandbox is slightly different from Jinja 1 as the
    default behavior is easier to use.

    The behavior can be changed by subclassing the environment.

    :copyright: (c) 2010 by the Jinja Team.
    :license: BSD.
i����N(tEnvironment(t
SecurityError(tstring_typest
function_typetmethod_typettraceback_typet	code_typet
frame_typetgenerator_typetPY2i��tfunc_closuret	func_codet	func_dictt
func_defaultstfunc_globalstim_classtim_functim_selftgi_frametgi_codetignoresthe sets moduletmodulesjinja2.sandbox(tdeque(tUserDictt	DictMixin(tUserList(tSet(t
MutableSettMutableMappingtMutableSequencetaddtcleartdifference_updatetdiscardtpoptremovetsymmetric_difference_updatetupdatetpopitemt
setdefaulttappendtreversetinserttsorttextendt
appendleftt
extendlefttpoplefttrotatecGs5t|�}t|�tkr1tdt��n|S(sWA range that can't generate ranges with a length of more than
    MAX_RANGE items.
    s+range too big, maximum size for range is %d(trangetlent	MAX_RANGEt
OverflowError(targstrng((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pyt
safe_range`s

cCs
t|_|S(snMarks a function or method as unsafe.

    ::

        @unsafe
        def delete(self):
            pass
    (tTruetunsafe_callable(tf((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pytunsafeks		cCs�t|t�r"|tkr�tSn�t|t�rP|tksI|tkr�tSn`t|t�rr|dkr�tSn>t|ttt	f�r�tSt|t
�r�|tkr�tSn|jd�S(s
Test if the attribute given is an internal python attribute.  For
    example this function returns `True` for the `func_code` attribute of
    python objects.  This is useful if the environment method
    :meth:`~SandboxedEnvironment.is_safe_attribute` is overridden.

    >>> from jinja2.sandbox import is_internal_attribute
    >>> is_internal_attribute(lambda: None, "func_code")
    True
    >>> is_internal_attribute((lambda x:x).func_code, 'co_code')
    True
    >>> is_internal_attribute(str, "upper")
    False
    tmrot__(
t
isinstanceRtUNSAFE_FUNCTION_ATTRIBUTESR8RtUNSAFE_METHOD_ATTRIBUTESttypeRRRRtUNSAFE_GENERATOR_ATTRIBUTESt
startswith(tobjtattr((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pytis_internal_attributexs cCs4x-tD]%\}}t||�r||kSqWtS(s�This function checks if an attribute on a builtin mutable object
    (list, dict, set or deque) would modify it if called.  It also supports
    the "user"-versions of the objects (`sets.Set`, `UserDict.*` etc.) and
    with Python 2.6 onwards the abstract base classes `MutableSet`,
    `MutableMapping`, and `MutableSequence`.

    >>> modifies_known_mutable({}, "clear")
    True
    >>> modifies_known_mutable({}, "keys")
    False
    >>> modifies_known_mutable([], "append")
    True
    >>> modifies_known_mutable([], "index")
    False

    If called with an unsupported object (such as unicode) `False` is
    returned.

    >>> modifies_known_mutable("foo", "upper")
    False
    (t
_mutable_specR>tFalse(RDREttypespecR;((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pytmodifies_known_mutable�stSandboxedEnvironmentcBs�eZdZeZiejd6ejd6ejd6ej	d6ej
d6ejd6ejd6Z
iejd6ejd6Ze�Ze�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�ZRS(s�The sandboxed environment.  It works like the regular environment but
    tells the compiler to generate sandboxed code.  Additionally subclasses of
    this environment may override the methods that tell the runtime what
    attributes or functions are safe to access.

    If the template tries to access insecure code a :exc:`SecurityError` is
    raised.  However also other exceptions may occour during the rendering so
    the caller has to ensure that all exceptions are catched.
    t+t-t*t/s//s**t%cCstS(s�Called during template compilation with the name of a unary
        operator to check if it should be intercepted at runtime.  If this
        method returns `True`, :meth:`call_unop` is excuted for this unary
        operator.  The default implementation of :meth:`call_unop` will use
        the :attr:`unop_table` dictionary to perform the operator with the
        same logic as the builtin one.

        The following unary operators are interceptable: ``+`` and ``-``

        Intercepted calls are always slower than the native operator call,
        so make sure only to intercept the ones you are interested in.

        .. versionadded:: 2.6
        (RH(tselftoperator((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pytintercept_unop�scOsHtj|||�t|jd<|jj�|_|jj�|_dS(NR1(	Rt__init__R7tglobalstdefault_binop_tabletcopytbinop_tabletdefault_unop_tablet
unop_table(RQR5tkwargs((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pyRTs
cCs|jd�pt||�S(sYThe sandboxed environment will call this method to check if the
        attribute of an object is safe to access.  Per default all attributes
        starting with an underscore are considered private as well as the
        special attributes of internal python objects as returned by the
        :func:`is_internal_attribute` function.
        t_(RCRF(RQRDREtvalue((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pytis_safe_attributescCs#t|dt�p!t|dt�S(sCheck if an object is safely callable.  Per default a function is
        considered safe unless the `unsafe_callable` attribute exists and is
        True.  Override this method to alter the behavior, but this won't
        affect the `unsafe` decorator from this module.
        R9talters_data(tgetattrRH(RQRD((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pytis_safe_callablescCs|j|||�S(s�For intercepted binary operator calls (:meth:`intercepted_binops`)
        this function is executed instead of the builtin operator.  This can
        be used to fine tune the behavior of certain operators.

        .. versionadded:: 2.6
        (RX(RQtcontextRRtlefttright((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pyt
call_binopscCs|j||�S(s�For intercepted unary operator calls (:meth:`intercepted_unops`)
        this function is executed instead of the builtin operator.  This can
        be used to fine tune the behavior of certain operators.

        .. versionadded:: 2.6
        (RZ(RQRbRRtarg((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pyt	call_unop'scCs�y||SWn�ttfk
r�t|t�r�yt|�}Wntk
rTq�Xyt||�}Wntk
r{q�X|j|||�r�|S|j	||�Sq�nX|j
d|d|�S(s(Subscribe an object from sandboxed code.RDtname(t	TypeErrortLookupErrorR>Rtstrt	ExceptionR`tAttributeErrorR^tunsafe_undefinedt	undefined(RQRDtargumentRER]((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pytgetitem0s 

cCs�yt||�}Wn7tk
rLy||SWqvttfk
rHqvXn*X|j|||�rf|S|j||�S|jd|d|�S(s�Subscribe an object from sandboxed code and prefer the
        attribute.  The attribute passed *must* be a bytestring.
        RDRh(R`RmRiRjR^RnRo(RQRDt	attributeR]((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pyR`Es
cCs/|jd||jjfd|d|dt�S(s1Return an undefined object for unsafe attributes.s.access to attribute %r of %r object is unsafe.RhRDtexc(Rot	__class__t__name__R(RQRDRr((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pyRnVs	cOs8|j|�s%td|f��n|j|||�S(s#Call an object from sandboxed code.s%r is not safely callable(RaRtcall(t_SandboxedEnvironment__selft_SandboxedEnvironment__contextt_SandboxedEnvironment__objR5R[((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pyRv^s(Rut
__module__t__doc__R8t	sandboxedRRRtsubtmulttruedivtfloordivtpowtmodRVtpostnegRYt	frozensettintercepted_binopstintercepted_unopsRSRTR^RaReRgRqR`RnRv(((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pyRK�s2	








															tImmutableSandboxedEnvironmentcBseZdZd�ZRS(s�Works exactly like the regular `SandboxedEnvironment` but does not
    permit modifications on the builtin mutable objects `list`, `set`, and
    `dict` by using the :func:`modifies_known_mutable` function.
    cCs*tj||||�stSt||�S(N(RKR^RHRJ(RQRDRER]((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pyR^ms(RuRzR{R^(((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pyR�gs(/R{RRtjinja2.environmentRtjinja2.exceptionsRtjinja2._compatRRRRRRRR	R3tsetR?R@RBtwarningstfilterwarningstDeprecationWarningtcollectionsRt_mutable_set_typestdictt_mutable_mapping_typestlistt_mutable_sequence_typesRRRtImportErrortsetsRRRRR�RGR7R;RFRJRKR�(((s?/opt/alt/python27/lib/python2.7/site-packages/jinja2/sandbox.pyt<module>sj:			




		
	 	�

Zerion Mini Shell 1.0