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

Method wrap

tools/inspector_protocol/jinja2/lexer.py:558–597  ·  view source on GitHub ↗

This is called with the stream as returned by `tokenize` and wraps every token in a :class:`Token` and converts the value.

(self, stream, name=None, filename=None)

Source from the content-addressed store, hash-verified

556 return TokenStream(self.wrap(stream, name, filename), name, filename)
557
558 def wrap(self, stream, name=None, filename=None):
559 """This is called with the stream as returned by `tokenize` and wraps
560 every token in a :class:`Token` and converts the value.
561 """
562 for lineno, token, value in stream:
563 if token in ignored_tokens:
564 continue
565 elif token == 'linestatement_begin':
566 token = 'block_begin'
567 elif token == 'linestatement_end':
568 token = 'block_end'
569 # we are not interested in those tokens in the parser
570 elif token in ('raw_begin', 'raw_end'):
571 continue
572 elif token == 'data':
573 value = self._normalize_newlines(value)
574 elif token == 'keyword':
575 token = value
576 elif token == 'name':
577 value = str(value)
578 if check_ident and not value.isidentifier():
579 raise TemplateSyntaxError(
580 'Invalid character in identifier',
581 lineno, name, filename)
582 elif token == 'string':
583 # try to unescape string
584 try:
585 value = self._normalize_newlines(value[1:-1]) \
586 .encode('ascii', 'backslashreplace') \
587 .decode('unicode-escape')
588 except Exception as e:
589 msg = str(e).split(':')[-1].strip()
590 raise TemplateSyntaxError(msg, lineno, name, filename)
591 elif token == 'integer':
592 value = int(value)
593 elif token == 'float':
594 value = float(value)
595 elif token == 'operator':
596 token = operators[value]
597 yield Token(lineno, token, value)
598
599 def tokeniter(self, source, name, filename=None, state=None):
600 """This method tokenizes the text and returns the tokens in a

Callers 15

tokenizeMethod · 0.95
do_wordwrapFunction · 0.45
commentMethod · 0.45
test.jsFile · 0.45
runGCTestsFunction · 0.45
testFinalizeAndWrapFunction · 0.45
runTestFunction · 0.45
type_bodyMethod · 0.45
writeMethod · 0.45

Calls 8

_normalize_newlinesMethod · 0.95
TemplateSyntaxErrorClass · 0.90
strFunction · 0.85
intFunction · 0.85
encodeMethod · 0.80
TokenClass · 0.70
decodeMethod · 0.65
splitMethod · 0.45

Tested by

no test coverage detected