aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/Jinja2/py3/patches/01-arcadia.patch
blob: b78b648b37308a691d252e89e7eb04ed94862bde (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
--- contrib/python/Jinja2/py3/jinja2/__init__.py	(index)
+++ contrib/python/Jinja2/py3/jinja2/__init__.py	(working tree)
@@ -25,6 +25,7 @@ from .loaders import FunctionLoader
 from .loaders import ModuleLoader as ModuleLoader
 from .loaders import PackageLoader as PackageLoader
 from .loaders import PrefixLoader as PrefixLoader
+from .loaders import ResourceLoader as ResourceLoader
 from .runtime import ChainableUndefined as ChainableUndefined
 from .runtime import DebugUndefined as DebugUndefined
 from .runtime import make_logging_undefined as make_logging_undefined
--- contrib/python/Jinja2/py3/jinja2/loaders.py	(index)
+++ contrib/python/Jinja2/py3/jinja2/loaders.py	(working tree)
@@ -650,3 +650,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)