Browse Source

Restoring authorship annotation for <floatdrop@yandex-team.ru>. Commit 1 of 2.

floatdrop 3 years ago
parent
commit
e63b84f1d3

+ 7 - 7
build/rules/go/vendor.policy

@@ -217,9 +217,9 @@ ALLOW .* -> vendor/github.com/gorilla/websocket
 # http sessions with cookie and filesystem session storage
 ALLOW .* -> vendor/github.com/gorilla/sessions
 
-# Package gorilla/schema fills a struct with form values
-ALLOW .* -> vendor/github.com/gorilla/schema
-
+# Package gorilla/schema fills a struct with form values 
+ALLOW .* -> vendor/github.com/gorilla/schema 
+ 
 # S2 geometry
 ALLOW .* -> vendor/github.com/golang/geo
 
@@ -1032,11 +1032,11 @@ ALLOW infra/infractl/.* -> vendor/gopkg.in/yaml.v3
 # CONTRIB-2445
 ALLOW psp -> vendor/github.com/zimmski/go-mutesting
 
-# CONTRIB-2460
-ALLOW .* -> vendor/github.com/dgraph-io/ristretto
-
+# CONTRIB-2460 
+ALLOW .* -> vendor/github.com/dgraph-io/ristretto 
+ 
 #
 # This section is for EXCEPTIONS. Add new rule above, not here.
 #
-
+ 
 DENY .* -> vendor/

+ 1 - 1
contrib/libs/ya.make

@@ -320,7 +320,7 @@ RECURSE(
     svm
     svt-hevc
     svt-vp9
-    szip
+    szip 
     t1ha
     taocrypt
     tbb

+ 16 - 16
contrib/python/Jinja2/py2/README.rst

@@ -1,12 +1,12 @@
 Jinja
 =====
-
+ 
 Jinja is a fast, expressive, extensible templating engine. Special
 placeholders in the template allow writing code similar to Python
 syntax. Then the template is passed data to render the final document.
-
+ 
 It includes:
-
+ 
 -   Template inheritance and inclusion.
 -   Define and import macros within templates.
 -   HTML templates can use autoescaping to prevent XSS from untrusted
@@ -20,7 +20,7 @@ It includes:
 -   Exceptions point to the correct line in templates to make debugging
     easier.
 -   Extensible filters, tests, functions, and even syntax.
-
+ 
 Jinja's philosophy is that while application logic belongs in Python if
 possible, it shouldn't make the template designer's job difficult by
 restricting functionality too much.
@@ -41,22 +41,22 @@ Install and update using `pip`_:
 In A Nutshell
 -------------
 
-.. code-block:: jinja
-
+.. code-block:: jinja 
+ 
     {% extends "base.html" %}
     {% block title %}Members{% endblock %}
-    {% block content %}
-      <ul>
-      {% for user in users %}
-        <li><a href="{{ user.url }}">{{ user.username }}</a></li>
-      {% endfor %}
-      </ul>
-    {% endblock %}
-
-
+    {% block content %} 
+      <ul> 
+      {% for user in users %} 
+        <li><a href="{{ user.url }}">{{ user.username }}</a></li> 
+      {% endfor %} 
+      </ul> 
+    {% endblock %} 
+ 
+ 
 Links
 -----
-
+ 
 -   Website: https://palletsprojects.com/p/jinja/
 -   Documentation: https://jinja.palletsprojects.com/
 -   Releases: https://pypi.org/project/Jinja2/

+ 4 - 4
contrib/python/Jinja2/py2/jinja2/__init__.py

@@ -1,11 +1,11 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*- 
 """Jinja is a template engine written in pure Python. It provides a
 non-XML syntax that supports inline expressions and an optional
 sandboxed environment.
-"""
+""" 
 from markupsafe import escape
 from markupsafe import Markup
-
+ 
 from .bccache import BytecodeCache
 from .bccache import FileSystemBytecodeCache
 from .bccache import MemcachedBytecodeCache
@@ -41,5 +41,5 @@ from .utils import environmentfunction
 from .utils import evalcontextfunction
 from .utils import is_undefined
 from .utils import select_autoescape
-
+ 
 __version__ = "2.11.3"

+ 85 - 85
contrib/python/Jinja2/py2/jinja2/_compat.py

@@ -1,110 +1,110 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*- 
 # flake8: noqa
 import marshal
-import sys
-
-PY2 = sys.version_info[0] == 2
+import sys 
+ 
+PY2 = sys.version_info[0] == 2 
 PYPY = hasattr(sys, "pypy_translation_info")
-_identity = lambda x: x
-
-if not PY2:
-    unichr = chr
-    range_type = range
-    text_type = str
-    string_types = (str,)
-    integer_types = (int,)
-
-    iterkeys = lambda d: iter(d.keys())
-    itervalues = lambda d: iter(d.values())
-    iteritems = lambda d: iter(d.items())
-
-    import pickle
-    from io import BytesIO, StringIO
-
-    NativeStringIO = StringIO
-
-    def reraise(tp, value, tb=None):
-        if value.__traceback__ is not tb:
-            raise value.with_traceback(tb)
-        raise value
-
-    ifilter = filter
-    imap = map
-    izip = zip
-    intern = sys.intern
-
-    implements_iterator = _identity
-    implements_to_string = _identity
-    encode_filename = _identity
-
+_identity = lambda x: x 
+ 
+if not PY2: 
+    unichr = chr 
+    range_type = range 
+    text_type = str 
+    string_types = (str,) 
+    integer_types = (int,) 
+ 
+    iterkeys = lambda d: iter(d.keys()) 
+    itervalues = lambda d: iter(d.values()) 
+    iteritems = lambda d: iter(d.items()) 
+ 
+    import pickle 
+    from io import BytesIO, StringIO 
+
+    NativeStringIO = StringIO 
+ 
+    def reraise(tp, value, tb=None): 
+        if value.__traceback__ is not tb: 
+            raise value.with_traceback(tb) 
+        raise value 
+ 
+    ifilter = filter 
+    imap = map 
+    izip = zip 
+    intern = sys.intern 
+ 
+    implements_iterator = _identity 
+    implements_to_string = _identity 
+    encode_filename = _identity 
+ 
     marshal_dump = marshal.dump
     marshal_load = marshal.load
 
-else:
-    unichr = unichr
-    text_type = unicode
-    range_type = xrange
-    string_types = (str, unicode)
-    integer_types = (int, long)
-
-    iterkeys = lambda d: d.iterkeys()
-    itervalues = lambda d: d.itervalues()
-    iteritems = lambda d: d.iteritems()
-
-    import cPickle as pickle
-    from cStringIO import StringIO as BytesIO, StringIO
-
-    NativeStringIO = BytesIO
-
+else: 
+    unichr = unichr 
+    text_type = unicode 
+    range_type = xrange 
+    string_types = (str, unicode) 
+    integer_types = (int, long) 
+ 
+    iterkeys = lambda d: d.iterkeys() 
+    itervalues = lambda d: d.itervalues() 
+    iteritems = lambda d: d.iteritems() 
+ 
+    import cPickle as pickle 
+    from cStringIO import StringIO as BytesIO, StringIO 
+
+    NativeStringIO = BytesIO 
+ 
     exec("def reraise(tp, value, tb=None):\n raise tp, value, tb")
-
-    from itertools import imap, izip, ifilter
-
-    intern = intern
-
-    def implements_iterator(cls):
-        cls.next = cls.__next__
-        del cls.__next__
-        return cls
-
-    def implements_to_string(cls):
-        cls.__unicode__ = cls.__str__
+ 
+    from itertools import imap, izip, ifilter 
+
+    intern = intern 
+ 
+    def implements_iterator(cls): 
+        cls.next = cls.__next__ 
+        del cls.__next__ 
+        return cls 
+ 
+    def implements_to_string(cls): 
+        cls.__unicode__ = cls.__str__ 
         cls.__str__ = lambda x: x.__unicode__().encode("utf-8")
-        return cls
-
-    def encode_filename(filename):
-        if isinstance(filename, unicode):
+        return cls 
+ 
+    def encode_filename(filename): 
+        if isinstance(filename, unicode): 
             return filename.encode("utf-8")
-        return filename
-
+        return filename 
+ 
     def marshal_dump(code, f):
         if isinstance(f, file):
             marshal.dump(code, f)
         else:
             f.write(marshal.dumps(code))
-
+ 
     def marshal_load(f):
         if isinstance(f, file):
             return marshal.load(f)
         return marshal.loads(f.read())
 
 
-def with_metaclass(meta, *bases):
-    """Create a base class with a metaclass."""
-    # This requires a bit of explanation: the basic idea is to make a
-    # dummy metaclass for one level of class instantiation that replaces
-    # itself with the actual metaclass.
-    class metaclass(type):
-        def __new__(cls, name, this_bases, d):
-            return meta(name, bases, d)
-
+def with_metaclass(meta, *bases): 
+    """Create a base class with a metaclass.""" 
+    # This requires a bit of explanation: the basic idea is to make a 
+    # dummy metaclass for one level of class instantiation that replaces 
+    # itself with the actual metaclass. 
+    class metaclass(type): 
+        def __new__(cls, name, this_bases, d): 
+            return meta(name, bases, d) 
+ 
     return type.__new__(metaclass, "temporary_class", (), {})
+ 
 
-
-try:
-    from urllib.parse import quote_from_bytes as url_quote
-except ImportError:
-    from urllib import quote as url_quote
+try: 
+    from urllib.parse import quote_from_bytes as url_quote 
+except ImportError: 
+    from urllib import quote as url_quote 
 
 
 try:

+ 1 - 1
contrib/python/Jinja2/py2/jinja2/_identifier.py

@@ -1,6 +1,6 @@
 import re
 
-# generated by scripts/generate_identifier_pattern.py
+# generated by scripts/generate_identifier_pattern.py 
 pattern = re.compile(
     r"[\w·̀-ͯ·҃-֑҇-ׇֽֿׁׂׅׄؐ-ًؚ-ٰٟۖ-ۜ۟-۪ۤۧۨ-ܑۭܰ-݊ަ-ް߫-߳ࠖ-࠙ࠛ-ࠣࠥ-ࠧࠩ-࡙࠭-࡛ࣔ-ࣣ࣡-ःऺ-़ा-ॏ॑-ॗॢॣঁ-ঃ়া-ৄেৈো-্ৗৢৣਁ-ਃ਼ਾ-ੂੇੈੋ-੍ੑੰੱੵઁ-ઃ઼ા-ૅે-ૉો-્ૢૣଁ-ଃ଼ା-ୄେୈୋ-୍ୖୗୢୣஂா-ூெ-ைொ-்ௗఀ-ఃా-ౄె-ైొ-్ౕౖౢౣಁ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕೖೢೣഁ-ഃാ-ൄെ-ൈൊ-്ൗൢൣංඃ්ා-ුූෘ-ෟෲෳัิ-ฺ็-๎ັິ-ູົຼ່-ໍ༹༘༙༵༷༾༿ཱ-྄྆྇ྍ-ྗྙ-ྼ࿆ါ-ှၖ-ၙၞ-ၠၢ-ၤၧ-ၭၱ-ၴႂ-ႍႏႚ-ႝ፝-፟ᜒ-᜔ᜲ-᜴ᝒᝓᝲᝳ឴-៓៝᠋-᠍ᢅᢆᢩᤠ-ᤫᤰ-᤻ᨗ-ᨛᩕ-ᩞ᩠-᩿᩼᪰-᪽ᬀ-ᬄ᬴-᭄᭫-᭳ᮀ-ᮂᮡ-ᮭ᯦-᯳ᰤ-᰷᳐-᳔᳒-᳨᳭ᳲ-᳴᳸᳹᷀-᷵᷻-᷿‿⁀⁔⃐-⃥⃜⃡-⃰℘℮⳯-⵿⳱ⷠ-〪ⷿ-゙゚〯꙯ꙴ-꙽ꚞꚟ꛰꛱ꠂ꠆ꠋꠣ-ꠧꢀꢁꢴ-ꣅ꣠-꣱ꤦ-꤭ꥇ-꥓ꦀ-ꦃ꦳-꧀ꧥꨩ-ꨶꩃꩌꩍꩻ-ꩽꪰꪲ-ꪴꪷꪸꪾ꪿꫁ꫫ-ꫯꫵ꫶ꯣ-ꯪ꯬꯭ﬞ︀-️︠-︯︳︴﹍-﹏_𐇽𐋠𐍶-𐍺𐨁-𐨃𐨅𐨆𐨌-𐨏𐨸-𐨿𐨺𐫦𐫥𑀀-𑀂𑀸-𑁆𑁿-𑂂𑂰-𑂺𑄀-𑄂𑄧-𑅳𑄴𑆀-𑆂𑆳-𑇊𑇀-𑇌𑈬-𑈷𑈾𑋟-𑋪𑌀-𑌃𑌼𑌾-𑍄𑍇𑍈𑍋-𑍍𑍗𑍢𑍣𑍦-𑍬𑍰-𑍴𑐵-𑑆𑒰-𑓃𑖯-𑖵𑖸-𑗀𑗜𑗝𑘰-𑙀𑚫-𑚷𑜝-𑜫𑰯-𑰶𑰸-𑰿𑲒-𑲧𑲩-𑲶𖫰-𖫴𖬰-𖬶𖽑-𖽾𖾏-𖾒𛲝𛲞𝅥-𝅩𝅭-𝅲𝅻-𝆂𝆅-𝆋𝆪-𝆭𝉂-𝉄𝨀-𝨶𝨻-𝩬𝩵𝪄𝪛-𝪟𝪡-𝪯𞀀-𞀆𞀈-𞀘𞀛-𞀡𞀣𞀤𞀦-𞣐𞀪-𞣖𞥄-𞥊󠄀-󠇯]+"  # noqa: B950
 )

+ 287 - 287
contrib/python/Jinja2/py2/jinja2/bccache.py

@@ -1,28 +1,28 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*- 
 """The optional bytecode cache system. This is useful if you have very
 complex template situations and the compilation of all those templates
 slows down your application too much.
-
+ 
 Situations where this is useful are often forking web applications that
 are initialized on the first request.
-"""
+""" 
 import errno
 import fnmatch
-import os
+import os 
 import stat
-import sys
-import tempfile
-from hashlib import sha1
+import sys 
+import tempfile 
+from hashlib import sha1 
 from os import listdir
 from os import path
-
+ 
 from ._compat import BytesIO
 from ._compat import marshal_dump
 from ._compat import marshal_load
 from ._compat import pickle
 from ._compat import text_type
 from .utils import open_if_exists
-
+ 
 bc_version = 4
 # Magic bytes to identify Jinja bytecode cache files. Contains the
 # Python major and minor version to avoid loading incompatible bytecode
@@ -32,291 +32,291 @@ bc_magic = (
     + pickle.dumps(bc_version, 2)
     + pickle.dumps((sys.version_info[0] << 24) | sys.version_info[1], 2)
 )
-
-
-class Bucket(object):
-    """Buckets 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.
-    """
-
-    def __init__(self, environment, key, checksum):
-        self.environment = environment
-        self.key = key
-        self.checksum = checksum
-        self.reset()
-
-    def reset(self):
-        """Resets the bucket (unloads the bytecode)."""
-        self.code = None
-
-    def load_bytecode(self, f):
-        """Loads bytecode from a file or file like object."""
-        # make sure the magic header is correct
-        magic = f.read(len(bc_magic))
-        if magic != bc_magic:
-            self.reset()
-            return
-        # the source code of the file changed, we need to reload
-        checksum = pickle.load(f)
-        if self.checksum != checksum:
-            self.reset()
-            return
-        # if marshal_load fails then we need to reload
-        try:
-            self.code = marshal_load(f)
-        except (EOFError, ValueError, TypeError):
-            self.reset()
-            return
-
-    def write_bytecode(self, f):
-        """Dump the bytecode into the file or file like object passed."""
-        if self.code is None:
+ 
+ 
+class Bucket(object): 
+    """Buckets 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. 
+    """ 
+ 
+    def __init__(self, environment, key, checksum): 
+        self.environment = environment 
+        self.key = key 
+        self.checksum = checksum 
+        self.reset() 
+ 
+    def reset(self): 
+        """Resets the bucket (unloads the bytecode).""" 
+        self.code = None 
+ 
+    def load_bytecode(self, f): 
+        """Loads bytecode from a file or file like object.""" 
+        # make sure the magic header is correct 
+        magic = f.read(len(bc_magic)) 
+        if magic != bc_magic: 
+            self.reset() 
+            return 
+        # the source code of the file changed, we need to reload 
+        checksum = pickle.load(f) 
+        if self.checksum != checksum: 
+            self.reset() 
+            return 
+        # if marshal_load fails then we need to reload 
+        try: 
+            self.code = marshal_load(f) 
+        except (EOFError, ValueError, TypeError): 
+            self.reset() 
+            return 
+ 
+    def write_bytecode(self, f): 
+        """Dump the bytecode into the file or file like object passed.""" 
+        if self.code is None: 
             raise TypeError("can't write empty bucket")
-        f.write(bc_magic)
-        pickle.dump(self.checksum, f, 2)
-        marshal_dump(self.code, f)
-
-    def bytecode_from_string(self, string):
-        """Load bytecode from a string."""
-        self.load_bytecode(BytesIO(string))
-
-    def bytecode_to_string(self):
-        """Return the bytecode as string."""
-        out = BytesIO()
-        self.write_bytecode(out)
-        return out.getvalue()
-
-
-class BytecodeCache(object):
-    """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
+        f.write(bc_magic) 
+        pickle.dump(self.checksum, f, 2) 
+        marshal_dump(self.code, f) 
+ 
+    def bytecode_from_string(self, string): 
+        """Load bytecode from a string.""" 
+        self.load_bytecode(BytesIO(string)) 
+ 
+    def bytecode_to_string(self): 
+        """Return the bytecode as string.""" 
+        out = BytesIO() 
+        self.write_bytecode(out) 
+        return out.getvalue() 
+ 
+ 
+class BytecodeCache(object): 
+    """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 
     Jinja.
-    """
-
-    def load_bytecode(self, bucket):
-        """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.
-        """
-        raise NotImplementedError()
-
-    def dump_bytecode(self, bucket):
-        """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.
-        """
-        raise NotImplementedError()
-
-    def clear(self):
+    """ 
+ 
+    def load_bytecode(self, bucket): 
+        """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. 
+        """ 
+        raise NotImplementedError() 
+ 
+    def dump_bytecode(self, bucket): 
+        """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. 
+        """ 
+        raise NotImplementedError() 
+ 
+    def clear(self): 
         """Clears the cache.  This method is not used by Jinja but should be
-        implemented to allow applications to clear the bytecode cache used
-        by a particular environment.
-        """
-
-    def get_cache_key(self, name, filename=None):
-        """Returns the unique hash key for this template name."""
+        implemented to allow applications to clear the bytecode cache used 
+        by a particular environment. 
+        """ 
+ 
+    def get_cache_key(self, name, filename=None): 
+        """Returns the unique hash key for this template name.""" 
         hash = sha1(name.encode("utf-8"))
-        if filename is not None:
+        if filename is not None: 
             filename = "|" + filename
-            if isinstance(filename, text_type):
+            if isinstance(filename, text_type): 
                 filename = filename.encode("utf-8")
-            hash.update(filename)
-        return hash.hexdigest()
-
-    def get_source_checksum(self, source):
-        """Returns a checksum for the source."""
+            hash.update(filename) 
+        return hash.hexdigest() 
+ 
+    def get_source_checksum(self, source): 
+        """Returns a checksum for the source.""" 
         return sha1(source.encode("utf-8")).hexdigest()
-
-    def get_bucket(self, environment, name, filename, source):
-        """Return a cache bucket for the given template.  All arguments are
-        mandatory but filename may be `None`.
-        """
-        key = self.get_cache_key(name, filename)
-        checksum = self.get_source_checksum(source)
-        bucket = Bucket(environment, key, checksum)
-        self.load_bytecode(bucket)
-        return bucket
-
-    def set_bucket(self, bucket):
-        """Put the bucket into the cache."""
-        self.dump_bytecode(bucket)
-
-
-class FileSystemBytecodeCache(BytecodeCache):
-    """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.
-    """
-
+ 
+    def get_bucket(self, environment, name, filename, source): 
+        """Return a cache bucket for the given template.  All arguments are 
+        mandatory but filename may be `None`. 
+        """ 
+        key = self.get_cache_key(name, filename) 
+        checksum = self.get_source_checksum(source) 
+        bucket = Bucket(environment, key, checksum) 
+        self.load_bytecode(bucket) 
+        return bucket 
+ 
+    def set_bucket(self, bucket): 
+        """Put the bucket into the cache.""" 
+        self.dump_bytecode(bucket) 
+ 
+ 
+class FileSystemBytecodeCache(BytecodeCache): 
+    """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. 
+    """ 
+ 
     def __init__(self, directory=None, pattern="__jinja2_%s.cache"):
-        if directory is None:
-            directory = self._get_default_cache_dir()
-        self.directory = directory
-        self.pattern = pattern
-
-    def _get_default_cache_dir(self):
-        def _unsafe_dir():
+        if directory is None: 
+            directory = self._get_default_cache_dir() 
+        self.directory = directory 
+        self.pattern = pattern 
+ 
+    def _get_default_cache_dir(self): 
+        def _unsafe_dir(): 
             raise RuntimeError(
                 "Cannot determine safe temp directory.  You "
                 "need to explicitly provide one."
             )
-
-        tmpdir = tempfile.gettempdir()
-
-        # On windows the temporary directory is used specific unless
-        # explicitly forced otherwise.  We can just use that.
+ 
+        tmpdir = tempfile.gettempdir() 
+ 
+        # On windows the temporary directory is used specific unless 
+        # explicitly forced otherwise.  We can just use that. 
         if os.name == "nt":
-            return tmpdir
+            return tmpdir 
         if not hasattr(os, "getuid"):
-            _unsafe_dir()
-
+            _unsafe_dir() 
+ 
         dirname = "_jinja2-cache-%d" % os.getuid()
-        actual_dir = os.path.join(tmpdir, dirname)
-
-        try:
-            os.mkdir(actual_dir, stat.S_IRWXU)
-        except OSError as e:
-            if e.errno != errno.EEXIST:
-                raise
-        try:
-            os.chmod(actual_dir, stat.S_IRWXU)
-            actual_dir_stat = os.lstat(actual_dir)
+        actual_dir = os.path.join(tmpdir, dirname) 
+ 
+        try: 
+            os.mkdir(actual_dir, stat.S_IRWXU) 
+        except OSError as e: 
+            if e.errno != errno.EEXIST: 
+                raise 
+        try: 
+            os.chmod(actual_dir, stat.S_IRWXU) 
+            actual_dir_stat = os.lstat(actual_dir) 
             if (
                 actual_dir_stat.st_uid != os.getuid()
                 or not stat.S_ISDIR(actual_dir_stat.st_mode)
                 or stat.S_IMODE(actual_dir_stat.st_mode) != stat.S_IRWXU
             ):
-                _unsafe_dir()
-        except OSError as e:
-            if e.errno != errno.EEXIST:
-                raise
-
-        actual_dir_stat = os.lstat(actual_dir)
+                _unsafe_dir() 
+        except OSError as e: 
+            if e.errno != errno.EEXIST: 
+                raise 
+ 
+        actual_dir_stat = os.lstat(actual_dir) 
         if (
             actual_dir_stat.st_uid != os.getuid()
             or not stat.S_ISDIR(actual_dir_stat.st_mode)
             or stat.S_IMODE(actual_dir_stat.st_mode) != stat.S_IRWXU
         ):
-            _unsafe_dir()
-
-        return actual_dir
-
-    def _get_cache_filename(self, bucket):
-        return path.join(self.directory, self.pattern % bucket.key)
-
-    def load_bytecode(self, bucket):
+            _unsafe_dir() 
+ 
+        return actual_dir 
+ 
+    def _get_cache_filename(self, bucket): 
+        return path.join(self.directory, self.pattern % bucket.key) 
+ 
+    def load_bytecode(self, bucket): 
         f = open_if_exists(self._get_cache_filename(bucket), "rb")
-        if f is not None:
-            try:
-                bucket.load_bytecode(f)
-            finally:
-                f.close()
-
-    def dump_bytecode(self, bucket):
+        if f is not None: 
+            try: 
+                bucket.load_bytecode(f) 
+            finally: 
+                f.close() 
+ 
+    def dump_bytecode(self, bucket): 
         f = open(self._get_cache_filename(bucket), "wb")
-        try:
-            bucket.write_bytecode(f)
-        finally:
-            f.close()
-
-    def clear(self):
-        # imported lazily here because google app-engine doesn't support
-        # write access on the file system and the function does not exist
-        # normally.
-        from os import remove
+        try: 
+            bucket.write_bytecode(f) 
+        finally: 
+            f.close() 
+ 
+    def clear(self): 
+        # imported lazily here because google app-engine doesn't support 
+        # write access on the file system and the function does not exist 
+        # normally. 
+        from os import remove 
 
         files = fnmatch.filter(listdir(self.directory), self.pattern % "*")
-        for filename in files:
-            try:
-                remove(path.join(self.directory, filename))
-            except OSError:
-                pass
-
-
-class MemcachedBytecodeCache(BytecodeCache):
-    """This 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:
-
+        for filename in files: 
+            try: 
+                remove(path.join(self.directory, filename)) 
+            except OSError: 
+                pass 
+ 
+ 
+class MemcachedBytecodeCache(BytecodeCache): 
+    """This 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: 
+ 
     -   `cachelib <https://github.com/pallets/cachelib>`_
     -   `python-memcached <https://pypi.org/project/python-memcached/>`_
-
-    (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.
-    """
-
+ 
+    (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. 
+    """ 
+ 
     def __init__(
         self,
         client,
@@ -324,27 +324,27 @@ class MemcachedBytecodeCache(BytecodeCache):
         timeout=None,
         ignore_memcache_errors=True,
     ):
-        self.client = client
-        self.prefix = prefix
-        self.timeout = timeout
-        self.ignore_memcache_errors = ignore_memcache_errors
-
-    def load_bytecode(self, bucket):
-        try:
-            code = self.client.get(self.prefix + bucket.key)
-        except Exception:
-            if not self.ignore_memcache_errors:
-                raise
-            code = None
-        if code is not None:
-            bucket.bytecode_from_string(code)
-
-    def dump_bytecode(self, bucket):
-        args = (self.prefix + bucket.key, bucket.bytecode_to_string())
-        if self.timeout is not None:
-            args += (self.timeout,)
-        try:
-            self.client.set(*args)
-        except Exception:
-            if not self.ignore_memcache_errors:
-                raise
+        self.client = client 
+        self.prefix = prefix 
+        self.timeout = timeout 
+        self.ignore_memcache_errors = ignore_memcache_errors 
+ 
+    def load_bytecode(self, bucket): 
+        try: 
+            code = self.client.get(self.prefix + bucket.key) 
+        except Exception: 
+            if not self.ignore_memcache_errors: 
+                raise 
+            code = None 
+        if code is not None: 
+            bucket.bytecode_from_string(code) 
+ 
+    def dump_bytecode(self, bucket): 
+        args = (self.prefix + bucket.key, bucket.bytecode_to_string()) 
+        if self.timeout is not None: 
+            args += (self.timeout,) 
+        try: 
+            self.client.set(*args) 
+        except Exception: 
+            if not self.ignore_memcache_errors: 
+                raise 

File diff suppressed because it is too large
+ 474 - 474
contrib/python/Jinja2/py2/jinja2/compiler.py


+ 19 - 19
contrib/python/Jinja2/py2/jinja2/constants.py

@@ -1,21 +1,21 @@
-# -*- coding: utf-8 -*-
-#: list of lorem ipsum words used by the lipsum() helper function
+# -*- coding: utf-8 -*- 
+#: list of lorem ipsum words used by the lipsum() helper function 
 LOREM_IPSUM_WORDS = u"""\
-a ac accumsan ad adipiscing aenean aliquam aliquet amet ante aptent arcu at
-auctor augue bibendum blandit class commodo condimentum congue consectetuer
-consequat conubia convallis cras cubilia cum curabitur curae cursus dapibus
-diam dictum dictumst dignissim dis dolor donec dui duis egestas eget eleifend
-elementum elit enim erat eros est et etiam eu euismod facilisi facilisis fames
-faucibus felis fermentum feugiat fringilla fusce gravida habitant habitasse hac
-hendrerit hymenaeos iaculis id imperdiet in inceptos integer interdum ipsum
-justo lacinia lacus laoreet lectus leo libero ligula litora lobortis lorem
-luctus maecenas magna magnis malesuada massa mattis mauris metus mi molestie
-mollis montes morbi mus nam nascetur natoque nec neque netus nibh nisi nisl non
-nonummy nostra nulla nullam nunc odio orci ornare parturient pede pellentesque
-penatibus per pharetra phasellus placerat platea porta porttitor posuere
-potenti praesent pretium primis proin pulvinar purus quam quis quisque rhoncus
-ridiculus risus rutrum sagittis sapien scelerisque sed sem semper senectus sit
-sociis sociosqu sodales sollicitudin suscipit suspendisse taciti tellus tempor
-tempus tincidunt torquent tortor tristique turpis ullamcorper ultrices
-ultricies urna ut varius vehicula vel velit venenatis vestibulum vitae vivamus
+a ac accumsan ad adipiscing aenean aliquam aliquet amet ante aptent arcu at 
+auctor augue bibendum blandit class commodo condimentum congue consectetuer 
+consequat conubia convallis cras cubilia cum curabitur curae cursus dapibus 
+diam dictum dictumst dignissim dis dolor donec dui duis egestas eget eleifend 
+elementum elit enim erat eros est et etiam eu euismod facilisi facilisis fames 
+faucibus felis fermentum feugiat fringilla fusce gravida habitant habitasse hac 
+hendrerit hymenaeos iaculis id imperdiet in inceptos integer interdum ipsum 
+justo lacinia lacus laoreet lectus leo libero ligula litora lobortis lorem 
+luctus maecenas magna magnis malesuada massa mattis mauris metus mi molestie 
+mollis montes morbi mus nam nascetur natoque nec neque netus nibh nisi nisl non 
+nonummy nostra nulla nullam nunc odio orci ornare parturient pede pellentesque 
+penatibus per pharetra phasellus placerat platea porta porttitor posuere 
+potenti praesent pretium primis proin pulvinar purus quam quis quisque rhoncus 
+ridiculus risus rutrum sagittis sapien scelerisque sed sem semper senectus sit 
+sociis sociosqu sodales sollicitudin suscipit suspendisse taciti tellus tempor 
+tempus tincidunt torquent tortor tristique turpis ullamcorper ultrices 
+ultricies urna ut varius vehicula vel velit venenatis vestibulum vitae vivamus 
 viverra volutpat vulputate"""

+ 69 - 69
contrib/python/Jinja2/py2/jinja2/debug.py

@@ -1,19 +1,19 @@
-import sys
+import sys 
 from types import CodeType
-
+ 
 from . import TemplateSyntaxError
 from ._compat import PYPY
 from .utils import internal_code
 from .utils import missing
-
-
+ 
+ 
 def rewrite_traceback_stack(source=None):
     """Rewrite the current exception to replace any tracebacks from
     within compiled template code with tracebacks that look like they
     came from the template source.
-
+ 
     This must be called within an ``except`` block.
-
+ 
     :param exc_info: A :meth:`sys.exc_info` tuple. If not provided,
         the current ``exc_info`` is used.
     :param source: For ``TemplateSyntaxError``, the original source if
@@ -21,18 +21,18 @@ def rewrite_traceback_stack(source=None):
     :return: A :meth:`sys.exc_info` tuple that can be re-raised.
     """
     exc_type, exc_value, tb = sys.exc_info()
-
+ 
     if isinstance(exc_value, TemplateSyntaxError) and not exc_value.translated:
         exc_value.translated = True
         exc_value.source = source
-
+ 
         try:
             # Remove the old traceback on Python 3, otherwise the frames
             # from the compiler still show up.
             exc_value.with_traceback(None)
         except AttributeError:
             pass
-
+ 
         # Outside of runtime, so the frame isn't executing template
         # code, but it still needs to point at the template.
         tb = fake_traceback(
@@ -41,9 +41,9 @@ def rewrite_traceback_stack(source=None):
     else:
         # Skip the frame for the render function.
         tb = tb.tb_next
-
+ 
     stack = []
-
+ 
     # Build the stack of traceback object, replacing any in template
     # code with the source file and line information.
     while tb is not None:
@@ -52,33 +52,33 @@ def rewrite_traceback_stack(source=None):
         if tb.tb_frame.f_code in internal_code:
             tb = tb.tb_next
             continue
-
+ 
         template = tb.tb_frame.f_globals.get("__jinja_template__")
-
+ 
         if template is not None:
             lineno = template.get_corresponding_lineno(tb.tb_lineno)
             fake_tb = fake_traceback(exc_value, tb, template.filename, lineno)
             stack.append(fake_tb)
-        else:
+        else: 
             stack.append(tb)
-
+ 
         tb = tb.tb_next
-
+ 
     tb_next = None
-
+ 
     # Assign tb_next in reverse to avoid circular references.
     for tb in reversed(stack):
         tb_next = tb_set_next(tb, tb_next)
-
+ 
     return exc_type, exc_value, tb_next
-
-
+ 
+ 
 def fake_traceback(exc_value, tb, filename, lineno):
     """Produce a new traceback object that looks like it came from the
     template source instead of the compiled code. The filename, line
     number, and location name will point to the template, and the local
     variables will be the current template context.
-
+ 
     :param exc_value: The original exception to be re-raised to create
         the new traceback.
     :param tb: The original traceback to get the local variables and
@@ -91,9 +91,9 @@ def fake_traceback(exc_value, tb, filename, lineno):
         # available at that point in the template.
         locals = get_template_locals(tb.tb_frame.f_locals)
         locals.pop("__jinja_exception__", None)
-    else:
+    else: 
         locals = {}
-
+ 
     globals = {
         "__name__": filename,
         "__file__": filename,
@@ -101,25 +101,25 @@ def fake_traceback(exc_value, tb, filename, lineno):
     }
     # Raise an exception at the correct line number.
     code = compile("\n" * (lineno - 1) + "raise __jinja_exception__", filename, "exec")
-
+ 
     # Build a new code object that points to the template file and
     # replaces the location with a block name.
     try:
         location = "template"
-
+ 
         if tb is not None:
             function = tb.tb_frame.f_code.co_name
-
+ 
             if function == "root":
                 location = "top-level template code"
             elif function.startswith("block_"):
                 location = 'block "%s"' % function[6:]
-
+ 
         # Collect arguments for the new code object. CodeType only
         # accepts positional arguments, and arguments were inserted in
         # new Python versions.
         code_args = []
-
+ 
         for attr in (
             "argcount",
             "posonlyargcount",  # Python 3.8
@@ -142,88 +142,88 @@ def fake_traceback(exc_value, tb, filename, lineno):
                 # Replace with given value.
                 code_args.append(attr[1])
                 continue
-
+ 
             try:
                 # Copy original value if it exists.
                 code_args.append(getattr(code, "co_" + attr))
             except AttributeError:
                 # Some arguments were added later.
                 continue
-
+ 
         code = CodeType(*code_args)
     except Exception:
         # Some environments such as Google App Engine don't support
         # modifying code objects.
         pass
-
+ 
     # Execute the new code, which is guaranteed to raise, and return
     # the new traceback without this frame.
     try:
         exec(code, globals, locals)
     except BaseException:
         return sys.exc_info()[2].tb_next
-
-
+ 
+ 
 def get_template_locals(real_locals):
     """Based on the runtime locals, get the context that would be
     available at that point in the template.
     """
     # Start with the current template context.
     ctx = real_locals.get("context")
-
-    if ctx:
+ 
+    if ctx: 
         data = ctx.get_all().copy()
-    else:
+    else: 
         data = {}
-
+ 
     # Might be in a derived context that only sets local variables
     # rather than pushing a context. Local variables follow the scheme
     # l_depth_name. Find the highest-depth local that has a value for
     # each name.
-    local_overrides = {}
-
+    local_overrides = {} 
+ 
     for name, value in real_locals.items():
         if not name.startswith("l_") or value is missing:
             # Not a template variable, or no longer relevant.
-            continue
+            continue 
 
-        try:
+        try: 
             _, depth, name = name.split("_", 2)
-            depth = int(depth)
-        except ValueError:
-            continue
-
-        cur_depth = local_overrides.get(name, (-1,))[0]
+            depth = int(depth) 
+        except ValueError: 
+            continue 
 
-        if cur_depth < depth:
-            local_overrides[name] = (depth, value)
+        cur_depth = local_overrides.get(name, (-1,))[0] 
 
+        if cur_depth < depth: 
+            local_overrides[name] = (depth, value) 
+ 
     # Modify the context with any derived context.
     for name, (_, value) in local_overrides.items():
-        if value is missing:
+        if value is missing: 
             data.pop(name, None)
-        else:
+        else: 
             data[name] = value
-
+ 
     return data
-
-
+ 
+ 
 if sys.version_info >= (3, 7):
     # tb_next is directly assignable as of Python 3.7
     def tb_set_next(tb, tb_next):
         tb.tb_next = tb_next
         return tb
-
-
+ 
+ 
 elif PYPY:
     # PyPy might have special support, and won't work with ctypes.
-    try:
+    try: 
         import tputil
     except ImportError:
         # Without tproxy support, use the original traceback.
         def tb_set_next(tb, tb_next):
             return tb
-
+ 
     else:
         # With tproxy support, create a proxy around the traceback that
         # returns the new tb_next.
@@ -231,38 +231,38 @@ elif PYPY:
             def controller(op):
                 if op.opname == "__getattribute__" and op.args[0] == "tb_next":
                     return tb_next
-
+ 
                 return op.delegate()
-
+ 
             return tputil.make_proxy(controller, obj=tb)
-
-
+ 
+ 
 else:
     # Use ctypes to assign tb_next at the C level since it's read-only
     # from Python.
-    import ctypes
-
+    import ctypes 
+ 
     class _CTraceback(ctypes.Structure):
         _fields_ = [
             # Extra PyObject slots when compiled with Py_TRACE_REFS.
             ("PyObject_HEAD", ctypes.c_byte * object().__sizeof__()),
             # Only care about tb_next as an object, not a traceback.
             ("tb_next", ctypes.py_object),
-        ]
-
+        ] 
+ 
     def tb_set_next(tb, tb_next):
         c_tb = _CTraceback.from_address(id(tb))
-
+ 
         # Clear out the old tb_next.
-        if tb.tb_next is not None:
+        if tb.tb_next is not None: 
             c_tb_next = ctypes.py_object(tb.tb_next)
             c_tb.tb_next = ctypes.py_object()
             ctypes.pythonapi.Py_DecRef(c_tb_next)
-
+ 
         # Assign the new tb_next.
         if tb_next is not None:
             c_tb_next = ctypes.py_object(tb_next)
             ctypes.pythonapi.Py_IncRef(c_tb_next)
             c_tb.tb_next = c_tb_next
-
+ 
         return tb

Some files were not shown because too many files changed in this diff