MCPcopy Create free account
hub / github.com/nodejs/node / overlay

Method overlay

deps/v8/third_party/jinja2/environment.py:384–450  ·  view source on GitHub ↗

Create a new overlay environment that shares all the data with the current environment except for cache and the overridden attributes. Extensions cannot be removed for an overlayed environment. An overlayed environment automatically gets all the extensions of the environment

(
        self,
        block_start_string: str = missing,
        block_end_string: str = missing,
        variable_start_string: str = missing,
        variable_end_string: str = missing,
        comment_start_string: str = missing,
        comment_end_string: str = missing,
        line_statement_prefix: t.Optional[str] = missing,
        line_comment_prefix: t.Optional[str] = missing,
        trim_blocks: bool = missing,
        lstrip_blocks: bool = missing,
        newline_sequence: "te.Literal['\\n', '\\r\\n', '\\r']" = missing,
        keep_trailing_newline: bool = missing,
        extensions: t.Sequence[t.Union[str, t.Type["Extension"]]] = missing,
        optimized: bool = missing,
        undefined: t.Type[Undefined] = missing,
        finalize: t.Optional[t.Callable[..., t.Any]] = missing,
        autoescape: t.Union[bool, t.Callable[[t.Optional[str]], bool]] = missing,
        loader: t.Optional["BaseLoader"] = missing,
        cache_size: int = missing,
        auto_reload: bool = missing,
        bytecode_cache: t.Optional["BytecodeCache"] = missing,
        enable_async: bool = False,
    )

Source from the content-addressed store, hash-verified

382 setattr(self, key, value)
383
384 def overlay(
385 self,
386 block_start_string: str = missing,
387 block_end_string: str = missing,
388 variable_start_string: str = missing,
389 variable_end_string: str = missing,
390 comment_start_string: str = missing,
391 comment_end_string: str = missing,
392 line_statement_prefix: t.Optional[str] = missing,
393 line_comment_prefix: t.Optional[str] = missing,
394 trim_blocks: bool = missing,
395 lstrip_blocks: bool = missing,
396 newline_sequence: "te.Literal['\\n', '\\r\\n', '\\r']" = missing,
397 keep_trailing_newline: bool = missing,
398 extensions: t.Sequence[t.Union[str, t.Type["Extension"]]] = missing,
399 optimized: bool = missing,
400 undefined: t.Type[Undefined] = missing,
401 finalize: t.Optional[t.Callable[..., t.Any]] = missing,
402 autoescape: t.Union[bool, t.Callable[[t.Optional[str]], bool]] = missing,
403 loader: t.Optional["BaseLoader"] = missing,
404 cache_size: int = missing,
405 auto_reload: bool = missing,
406 bytecode_cache: t.Optional["BytecodeCache"] = missing,
407 enable_async: bool = False,
408 ) -> "Environment":
409 """Create a new overlay environment that shares all the data with the
410 current environment except for cache and the overridden attributes.
411 Extensions cannot be removed for an overlayed environment. An overlayed
412 environment automatically gets all the extensions of the environment it
413 is linked to plus optional extra extensions.
414
415 Creating overlays should happen after the initial environment was set
416 up completely. Not all attributes are truly linked, some are just
417 copied over so modifications on the original environment may not shine
418 through.
419
420 .. versionchanged:: 3.1.2
421 Added the ``newline_sequence``,, ``keep_trailing_newline``,
422 and ``enable_async`` parameters to match ``__init__``.
423 """
424 args = dict(locals())
425 del args["self"], args["cache_size"], args["extensions"], args["enable_async"]
426
427 rv = object.__new__(self.__class__)
428 rv.__dict__.update(self.__dict__)
429 rv.overlayed = True
430 rv.linked_to = self
431
432 for key, value in args.items():
433 if value is not missing:
434 setattr(rv, key, value)
435
436 if cache_size is not missing:
437 rv.cache = create_cache(cache_size)
438 else:
439 rv.cache = copy_cache(self.cache)
440
441 rv.extensions = {}

Callers

nothing calls this directly

Calls 8

create_cacheFunction · 0.70
copy_cacheFunction · 0.70
load_extensionsFunction · 0.70
updateMethod · 0.65
__new__Method · 0.45
itemsMethod · 0.45
bindMethod · 0.45

Tested by

no test coverage detected