aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Jinja2/py2/patches/01-arcadia.patch
blob: d1856974f93e7c03027e5a272b7dffbace90cbaf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
--- contrib/python/Jinja2/py2/jinja2/__init__.py	(index)
+++ contrib/python/Jinja2/py2/jinja2/__init__.py	(working tree)
@@ -29,6 +29,7 @@ from .loaders import FunctionLoader
 from .loaders import ModuleLoader
 from .loaders import PackageLoader
 from .loaders import PrefixLoader
+from .loaders import ResourceLoader
 from .runtime import ChainableUndefined
 from .runtime import DebugUndefined
 from .runtime import make_logging_undefined
--- contrib/python/Jinja2/py2/jinja2/loaders.py	(index)
+++ contrib/python/Jinja2/py2/jinja2/loaders.py	(working tree)
@@ -502,3 +502,17 @@ class ModuleLoader(BaseLoader):
         return environment.template_class.from_module_dict(
             environment, mod.__dict__, globals
         )
+
+
+class ResourceLoader(BaseLoader):
+    def __init__(self, prefix, module_loader):
+        self.prefix = prefix
+        self.module_loader = module_loader
+
+    def get_source(self, environment, template):
+        if self.module_loader is None:
+            raise TemplateNotFound(template)
+        try:
+            return self.module_loader.get_data(os.path.join(self.prefix, template)).decode('utf-8'), None, None
+        except IOError:
+            raise TemplateNotFound(template)
--- contrib/python/Jinja2/py2/jinja2/nativetypes.py	(index)
+++ contrib/python/Jinja2/py2/jinja2/nativetypes.py	(working tree)
@@ -91,4 +91,4 @@ class NativeTemplate(Template):
             return self.environment.handle_exception()
 
 
-NativeEnvironment.template_class = NativeTemplate
+NativeEnvironment.template_class = NativeTemplate  # type: ignore