Parse Python expression and detects whether last token is ';
(expression)
| 98 | |
| 99 | @staticmethod |
| 100 | def semicolon_at_end_of_expression(expression): |
| 101 | """Parse Python expression and detects whether last token is ';'""" |
| 102 | |
| 103 | sio = _io.StringIO(expression) |
| 104 | tokens = list(tokenize.generate_tokens(sio.readline)) |
| 105 | |
| 106 | for token in reversed(tokens): |
| 107 | if token[0] in (tokenize.ENDMARKER, tokenize.NL, tokenize.NEWLINE, tokenize.COMMENT): |
| 108 | continue |
| 109 | if (token[0] == tokenize.OP) and (token[1] == ';'): |
| 110 | return True |
| 111 | else: |
| 112 | return False |
| 113 | |
| 114 | def start_displayhook(self): |
| 115 | """Start the displayhook, initializing resources.""" |
no outgoing calls
no test coverage detected