wrap generate_tokens to catch EOF errors
(readline)
| 13 | Token = namedtuple('Token', ['token', 'text', 'start', 'end', 'line']) |
| 14 | |
| 15 | def generate_tokens(readline): |
| 16 | """wrap generate_tokens to catch EOF errors""" |
| 17 | try: |
| 18 | for token in tokenize.generate_tokens(readline): |
| 19 | yield token |
| 20 | except tokenize.TokenError: |
| 21 | # catch EOF error |
| 22 | return |
| 23 | |
| 24 | def line_at_cursor(cell, cursor_pos=0): |
| 25 | """Return the line in a cell at a given cursor position |
no outgoing calls
no test coverage detected