Пример #1
0
 def __init__(self, runtime_engine_factory, engine, key_factory):
     self.lock = allocate_lock()
     self.runtime_engines = {}
     self.runtime_engine_factory = runtime_engine_factory
     self.engine = engine
     self.loader = engine.loader
     self.key_factory = key_factory
     template_class = self.engine.template_class
     self.engine.template_class = lambda name, render_template: \
         template_class(name, lambda ctx, local_defs, super_defs:
                        self.render(name, ctx, local_defs, super_defs))
Пример #2
0
 def __init__(self, loader, extensions, template_class=None):
     self.lock = allocate_lock()
     self.templates = {}
     self.renders = {}
     self.modules = {}
     self.global_vars = {'_r': self.render, '_i': self.import_name}
     self.loader = loader
     self.template_class = template_class or Template
     self.compiler = Compiler(self.global_vars, -2)
     self.lexer = Lexer(**lexer_scan(extensions))
     self.parser = Parser(**parser_scan(extensions))
     self.builder = SourceBuilder(**builder_scan(extensions))
Пример #3
0
 def __init__(self, loader, extensions, template_class=None):
     self.lock = allocate_lock()
     self.templates = {}
     self.renders = {}
     self.modules = {}
     self.global_vars = {
         '_r': self.render,
         '_i': self.import_name
     }
     self.loader = loader
     self.template_class = template_class or Template
     self.compiler = Compiler(self.global_vars, -2)
     self.lexer = Lexer(**lexer_scan(extensions))
     self.parser = Parser(**parser_scan(extensions))
     self.builder = SourceBuilder(**builder_scan(extensions))
Пример #4
0
 def __init__(
     self,
     loader: Loader,
     extensions: typing.List[typing.Any],
     template_class: typing.Optional[TemplateClass] = None,
 ) -> None:
     self.lock = allocate_lock()
     self.templates: typing.Dict[str, SupportsRender] = {}
     self.renders: typing.Dict[str, RenderTemplate] = {}
     self.modules: typing.Dict[str, ModuleType] = {}
     self.global_vars = {"_r": self.render, "_i": self.import_name}
     self.loader = loader
     self.template_class = template_class or Template
     self.compiler = Compiler(self.global_vars, -2)
     self.lexer = Lexer(**lexer_scan(extensions))
     self.parser = Parser(**parser_scan(extensions))
     self.builder = SourceBuilder(**builder_scan(extensions))
Пример #5
0
 def __init__(
     self,
     runtime_engine_factory: typing.Callable[[Loader], Engine],
     engine: Engine,
     key_factory: typing.Callable[[typing.Mapping[str, typing.Any]], str],
 ) -> None:
     self.lock = allocate_lock()
     self.runtime_engines: typing.Dict[str, Engine] = {}
     self.runtime_engine_factory = runtime_engine_factory
     self.engine = engine
     self.loader = engine.loader
     self.key_factory = key_factory
     template_class = self.engine.template_class
     self.engine.template_class = lambda name, _: template_class(
         name,
         lambda ctx, local_defs, super_defs: self.render(
             name, ctx, local_defs, super_defs
         ),
     )