Process data block for INPUT token.
(self, data, input_prompt, lineno)
| 436 | |
| 437 | # Callbacks for each type of token |
| 438 | def process_input(self, data, input_prompt, lineno): |
| 439 | """ |
| 440 | Process data block for INPUT token. |
| 441 | |
| 442 | """ |
| 443 | decorator, input, rest = data |
| 444 | image_file = None |
| 445 | image_directive = None |
| 446 | |
| 447 | is_verbatim = decorator=='@verbatim' or self.is_verbatim |
| 448 | is_doctest = (decorator is not None and \ |
| 449 | decorator.startswith('@doctest')) or self.is_doctest |
| 450 | is_suppress = decorator=='@suppress' or self.is_suppress |
| 451 | is_okexcept = decorator=='@okexcept' or self.is_okexcept |
| 452 | is_okwarning = decorator=='@okwarning' or self.is_okwarning |
| 453 | is_savefig = decorator is not None and \ |
| 454 | decorator.startswith('@savefig') |
| 455 | |
| 456 | input_lines = input.split('\n') |
| 457 | if len(input_lines) > 1: |
| 458 | if input_lines[-1] != "": |
| 459 | input_lines.append('') # make sure there's a blank line |
| 460 | # so splitter buffer gets reset |
| 461 | |
| 462 | continuation = ' %s:'%''.join(['.']*(len(str(lineno))+2)) |
| 463 | |
| 464 | if is_savefig: |
| 465 | image_file, image_directive = self.process_image(decorator) |
| 466 | |
| 467 | ret = [] |
| 468 | is_semicolon = False |
| 469 | |
| 470 | # Hold the execution count, if requested to do so. |
| 471 | if is_suppress and self.hold_count: |
| 472 | store_history = False |
| 473 | else: |
| 474 | store_history = True |
| 475 | |
| 476 | # Note: catch_warnings is not thread safe |
| 477 | with warnings.catch_warnings(record=True) as ws: |
| 478 | if input_lines[0].endswith(';'): |
| 479 | is_semicolon = True |
| 480 | #for i, line in enumerate(input_lines): |
| 481 | |
| 482 | # process the first input line |
| 483 | if is_verbatim: |
| 484 | self.process_input_lines(['']) |
| 485 | self.IP.execution_count += 1 # increment it anyway |
| 486 | else: |
| 487 | # only submit the line in non-verbatim mode |
| 488 | self.process_input_lines(input_lines, store_history=store_history) |
| 489 | |
| 490 | if not is_suppress: |
| 491 | for i, line in enumerate(input_lines): |
| 492 | if i == 0: |
| 493 | formatted_line = '%s %s'%(input_prompt, line) |
| 494 | else: |
| 495 | formatted_line = '%s %s'%(continuation, line) |
no test coverage detected