Return whether a block of code is ready to execute, or should be continued This is a non-stateful API, and will reset the state of this InputSplitter. Parameters ---------- source : string Python input code, which can be multiline.
(self, source)
| 350 | return out |
| 351 | |
| 352 | def check_complete(self, source): |
| 353 | """Return whether a block of code is ready to execute, or should be continued |
| 354 | |
| 355 | This is a non-stateful API, and will reset the state of this InputSplitter. |
| 356 | |
| 357 | Parameters |
| 358 | ---------- |
| 359 | source : string |
| 360 | Python input code, which can be multiline. |
| 361 | |
| 362 | Returns |
| 363 | ------- |
| 364 | status : str |
| 365 | One of 'complete', 'incomplete', or 'invalid' if source is not a |
| 366 | prefix of valid code. |
| 367 | indent_spaces : int or None |
| 368 | The number of spaces by which to indent the next line of code. If |
| 369 | status is not 'incomplete', this is None. |
| 370 | """ |
| 371 | self.reset() |
| 372 | try: |
| 373 | self.push(source) |
| 374 | except SyntaxError: |
| 375 | # Transformers in IPythonInputSplitter can raise SyntaxError, |
| 376 | # which push() will not catch. |
| 377 | return 'invalid', None |
| 378 | else: |
| 379 | if self._is_invalid: |
| 380 | return 'invalid', None |
| 381 | elif self.push_accepts_more(): |
| 382 | return 'incomplete', self.get_indent_spaces() |
| 383 | else: |
| 384 | return 'complete', None |
| 385 | finally: |
| 386 | self.reset() |
| 387 | |
| 388 | def push(self, lines:str) -> bool: |
| 389 | """Push one or more lines of input. |