Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
ó
¡‹EYc@sƒdZddlmZmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZmZmZmZesÍejZejZnd„Zd„Zd	Zd
jdƒejedƒejejd
d>ejdBƒZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZ dS(sÉ
    jinja2.bccache
    ~~~~~~~~~~~~~~

    This module implements the bytecode cache system Jinja is optionally
    using.  This is useful if you have very complex template situations and
    the compiliation of all those templates slow down your application too
    much.

    Situations where this is useful are often forking web applications that
    are initialized on the first request.

    :copyright: (c) 2017 by the Jinja Team.
    :license: BSD.
iÿÿÿÿ(tpathtlistdirN(tsha1(topen_if_exists(tBytesIOtpickletPY2t	text_typecCs<t|tƒr"tj||ƒn|jtj|ƒƒdS(N(t
isinstancetfiletmarshaltdumptwritetdumps(tcodetf((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pytmarshal_dump$scCs/t|tƒrtj|ƒStj|jƒƒS(N(RR	R
tloadtloadstread(R((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pytmarshal_load*s
itj2tasciiiiiitBucketcBsDeZdZd„Zd„Zd„Zd„Zd„Zd„ZRS(suBuckets are used to store the bytecode for one template.  It's created
    and initialized by the bytecode cache and passed to the loading functions.

    The buckets get an internal checksum from the cache assigned and use this
    to automatically reject outdated cache material.  Individual bytecode
    cache subclasses don't have to care about cache invalidation.
    cCs)||_||_||_|jƒdS(N(tenvironmenttkeytchecksumtreset(tselfRRR((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyt__init__Es			cCs
d|_dS(s)Resets the bucket (unloads the bytecode).N(tNoneR(R((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyRKscCsš|jttƒƒ}|tkr/|jƒdStj|ƒ}|j|kr[|jƒdSyt|ƒ|_Wn%t	t
tfk
r•|jƒdSXdS(s/Loads bytecode from a file or file like object.N(Rtlentbc_magicRRRRRRtEOFErrort
ValueErrort	TypeError(RRtmagicR((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyt
load_bytecodeOs


cCsU|jdkrtdƒ‚n|jtƒtj|j|dƒt|j|ƒdS(s;Dump the bytecode into the file or file like object passed.scan't write empty bucketiN(	RRR#RR RRRR(RR((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pytwrite_bytecodebs

cCs|jt|ƒƒdS(sLoad bytecode from a string.N(R%R(Rtstring((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pytbytecode_from_stringjscCs tƒ}|j|ƒ|jƒS(sReturn the bytecode as string.(RR&tgetvalue(Rtout((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pytbytecode_to_stringns	
(	t__name__t
__module__t__doc__RRR%R&R(R+(((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyR<s					t
BytecodeCachecBsPeZdZd„Zd„Zd„Zdd„Zd„Zd„Z	d„Z
RS(	sßTo implement your own bytecode cache you have to subclass this class
    and override :meth:`load_bytecode` and :meth:`dump_bytecode`.  Both of
    these methods are passed a :class:`~jinja2.bccache.Bucket`.

    A very basic bytecode cache that saves the bytecode on the file system::

        from os import path

        class MyCache(BytecodeCache):

            def __init__(self, directory):
                self.directory = directory

            def load_bytecode(self, bucket):
                filename = path.join(self.directory, bucket.key)
                if path.exists(filename):
                    with open(filename, 'rb') as f:
                        bucket.load_bytecode(f)

            def dump_bytecode(self, bucket):
                filename = path.join(self.directory, bucket.key)
                with open(filename, 'wb') as f:
                    bucket.write_bytecode(f)

    A more advanced version of a filesystem based bytecode cache is part of
    Jinja2.
    cCs
tƒ‚dS(s¹Subclasses have to override this method to load bytecode into a
        bucket.  If they are not able to find code in the cache for the
        bucket, it must not do anything.
        N(tNotImplementedError(Rtbucket((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyR%’scCs
tƒ‚dS(sÀSubclasses have to override this method to write the bytecode
        from a bucket back to the cache.  If it unable to do so it must not
        fail silently but raise an exception.
        N(R0(RR1((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyt
dump_bytecode™scCsdS(s»Clears the cache.  This method is not used by Jinja2 but should be
        implemented to allow applications to clear the bytecode cache used
        by a particular environment.
        N((R((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pytclear scCsft|jdƒƒ}|dk	r\d|}t|tƒrL|jdƒ}n|j|ƒn|jƒS(s3Returns the unique hash key for this template name.sutf-8t|N(RtencodeRRRtupdatet	hexdigest(Rtnametfilenamethash((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyt
get_cache_key¦s
cCst|jdƒƒjƒS(s"Returns a checksum for the source.sutf-8(RR5R7(Rtsource((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pytget_source_checksum°scCsD|j||ƒ}|j|ƒ}t|||ƒ}|j|ƒ|S(swReturn a cache bucket for the given template.  All arguments are
        mandatory but filename may be `None`.
        (R;R=RR%(RRR8R9R<RRR1((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyt
get_bucket´s

cCs|j|ƒdS(sPut the bucket into the cache.N(R2(RR1((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyt
set_bucket¾sN(R,R-R.R%R2R3RR;R=R>R?(((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyR/us			
		
tFileSystemBytecodeCachecBsJeZdZddd„Zd„Zd„Zd„Zd„Zd„Z	RS(	sïA bytecode cache that stores bytecode on the filesystem.  It accepts
    two arguments: The directory where the cache items are stored and a
    pattern string that is used to build the filename.

    If no directory is specified a default cache directory is selected.  On
    Windows the user's temp directory is used, on UNIX systems a directory
    is created for the user in the system temp directory.

    The pattern can be used to have multiple separate caches operate on the
    same directory.  The default pattern is ``'__jinja2_%s.cache'``.  ``%s``
    is replaced with the cache key.

    >>> bcc = FileSystemBytecodeCache('/tmp/jinja_cache', '%s.cache')

    This bytecode cache supports clearing of the cache using the clear method.
    s__jinja2_%s.cachecCs1|dkr|jƒ}n||_||_dS(N(Rt_get_default_cache_dirt	directorytpattern(RRBRC((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyRÕs	cCs¬d„}tjƒ}tjdkr(|SttdƒsA|ƒndtjƒ}tjj||ƒ}ytj|t	j
ƒWn+tk
rª}|jtj
kr«‚q«nXystj|t	j
ƒtj|ƒ}|jtjƒkst	j|jƒst	j|jƒt	j
kr|ƒnWn+tk
rK}|jtj
krL‚qLnXtj|ƒ}|jtjƒksžt	j|jƒsžt	j|jƒt	j
kr¨|ƒn|S(NcSstdƒ‚dS(NsJCannot determine safe temp directory.  You need to explicitly provide one.(tRuntimeError(((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyt_unsafe_dirÜstnttgetuids_jinja2-cache-%d(ttempfilet
gettempdirtosR8thasattrRGRtjointmkdirtstattS_IRWXUtOSErrorterrnotEEXISTtchmodtlstattst_uidtS_ISDIRtst_modetS_IMODE(RREttmpdirtdirnamet
actual_dirtetactual_dir_stat((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyRAÛs:	



cCstj|j|j|jƒS(N(RRLRBRCR(RR1((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyt_get_cache_filenamescCsJt|j|ƒdƒ}|dk	rFz|j|ƒWd|jƒXndS(Ntrb(RR^RR%tclose(RR1R((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyR%s
cCs;t|j|ƒdƒ}z|j|ƒWd|jƒXdS(Ntwb(topenR^R&R`(RR1R((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyR2scCsxddlm}tjt|jƒ|jdƒ}x?|D]7}y|tj|j|ƒƒWq9t	k
roq9Xq9WdS(Niÿÿÿÿ(tremovet*(
RJRctfnmatchtfilterRRBRCRRLRP(RRctfilesR9((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyR3s"

N(
R,R-R.RRRAR^R%R2R3(((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyR@Ãs	)			tMemcachedBytecodeCachecBs2eZdZdded„Zd„Zd„ZRS(suThis class implements a bytecode cache that uses a memcache cache for
    storing the information.  It does not enforce a specific memcache library
    (tummy's memcache or cmemcache) but will accept any class that provides
    the minimal interface required.

    Libraries compatible with this class:

    -   `werkzeug <http://werkzeug.pocoo.org/>`_.contrib.cache
    -   `python-memcached <http://www.tummy.com/Community/software/python-memcached/>`_
    -   `cmemcache <http://gijsbert.org/cmemcache/>`_

    (Unfortunately the django cache interface is not compatible because it
    does not support storing binary data, only unicode.  You can however pass
    the underlying cache client to the bytecode cache which is available
    as `django.core.cache.cache._client`.)

    The minimal interface for the client passed to the constructor is this:

    .. class:: MinimalClientInterface

        .. method:: set(key, value[, timeout])

            Stores the bytecode in the cache.  `value` is a string and
            `timeout` the timeout of the key.  If timeout is not provided
            a default timeout or no timeout should be assumed, if it's
            provided it's an integer with the number of seconds the cache
            item should exist.

        .. method:: get(key)

            Returns the value for the cache key.  If the item does not
            exist in the cache the return value must be `None`.

    The other arguments to the constructor are the prefix for all keys that
    is added before the actual cache key and the timeout for the bytecode in
    the cache system.  We recommend a high (or no) timeout.

    This bytecode cache does not support clearing of used items in the cache.
    The clear method is a no-operation function.

    .. versionadded:: 2.7
       Added support for ignoring memcache errors through the
       `ignore_memcache_errors` parameter.
    sjinja2/bytecode/cCs(||_||_||_||_dS(N(tclienttprefixttimeouttignore_memcache_errors(RRiRjRkRl((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyRQs			cCsiy |jj|j|jƒ}Wn&tk
rH|js?‚nd}nX|dk	re|j|ƒndS(N(RitgetRjRt	ExceptionRlRR((RR1R((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyR%Xs 
	
cCsy|j|j|jƒf}|jdk	r>||jf7}ny|jj|ŒWn tk
rt|jsu‚qunXdS(N(	RjRR+RkRRitsetRnRl(RR1targs((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyR2bs
	N(R,R-R.RtTrueRR%R2(((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyRh#s
,	
(!R.RJRRtsysRNRQR
RHRethashlibRtjinja2.utilsRtjinja2._compatRRRRRRRRt
bc_versionR5R
tversion_infoR tobjectRR/R@Rh(((sC/home/tvault/.virtenv/lib/python2.7/site-packages/jinja2/bccache.pyt<module>s."			&9N`