Returns the first python token from the given text. >>> python_lookahead = Parser().python_lookahead >>> python_lookahead('for i in range(10):') 'for' >>> python_lookahead('else:') 'elsweb/template.py >>> python_lookahead(' x = 1') ' '
(self, text)
| 382 | return AssignmentNode(line.strip()), text |
| 383 | |
| 384 | def python_lookahead(self, text): |
| 385 | """Returns the first python token from the given text. |
| 386 | |
| 387 | >>> python_lookahead = Parser().python_lookahead |
| 388 | >>> python_lookahead('for i in range(10):') |
| 389 | 'for' |
| 390 | >>> python_lookahead('else:') |
| 391 | 'elsweb/template.py |
| 392 | >>> python_lookahead(' x = 1') |
| 393 | ' ' |
| 394 | """ |
| 395 | i = iter([text]) |
| 396 | readline = lambda: next(i) |
| 397 | tokens = tokenize.generate_tokens(readline) |
| 398 | return next(tokens)[1] |
| 399 | |
| 400 | def python_tokens(self, text): |
| 401 | i = iter([text]) |
no test coverage detected