MCPcopy Index your code
hub / github.com/nodejs/node / compile

Method compile

tools/inspector_protocol/jinja2/environment.py:554–591  ·  view source on GitHub ↗

Compile a node or template source code. The `name` parameter is the load name of the template after it was joined using :meth:`join_path` if necessary, not the filename on the file system. the `filename` parameter is the estimated filename of the template on the file

(self, source, name=None, filename=None, raw=False,
                defer_init=False)

Source from the content-addressed store, hash-verified

552
553 @internalcode
554 def compile(self, source, name=None, filename=None, raw=False,
555 defer_init=False):
556 """Compile a node or template source code. The `name` parameter is
557 the load name of the template after it was joined using
558 :meth:`join_path` if necessary, not the filename on the file system.
559 the `filename` parameter is the estimated filename of the template on
560 the file system. If the template came from a database or memory this
561 can be omitted.
562
563 The return value of this method is a python code object. If the `raw`
564 parameter is `True` the return value will be a string with python
565 code equivalent to the bytecode returned otherwise. This method is
566 mainly used internally.
567
568 `defer_init` is use internally to aid the module code generator. This
569 causes the generated code to be able to import without the global
570 environment variable to be set.
571
572 .. versionadded:: 2.4
573 `defer_init` parameter added.
574 """
575 source_hint = None
576 try:
577 if isinstance(source, string_types):
578 source_hint = source
579 source = self._parse(source, name, filename)
580 source = self._generate(source, name, filename,
581 defer_init=defer_init)
582 if raw:
583 return source
584 if filename is None:
585 filename = '<template>'
586 else:
587 filename = encode_filename(filename)
588 return self._compile(source, filename)
589 except TemplateSyntaxError:
590 exc_info = sys.exc_info()
591 self.handle_exception(exc_info, source_hint=source_hint)
592
593 def compile_expression(self, source, undefined_to_none=True):
594 """A handy helper method that returns a callable that accepts keyword

Callers 15

compile_templatesMethod · 0.95
from_stringMethod · 0.95
test.pyFile · 0.45
matchMethod · 0.45
ArgsToTestPathsFunction · 0.45
mkssldef.pyFile · 0.45
cpplint.pyFile · 0.45
ProcessConfigOverridesFunction · 0.45
__init__.pyFile · 0.45
loadMethod · 0.45

Calls 6

_parseMethod · 0.95
_generateMethod · 0.95
_compileMethod · 0.95
handle_exceptionMethod · 0.95
encode_filenameFunction · 0.90
exc_infoMethod · 0.80

Tested by 3

matchMethod · 0.36
ArgsToTestPathsFunction · 0.36
assert_fileFunction · 0.36