MCPcopy Index your code
hub / github.com/ipython/ipython / process_input

Method process_input

IPython/sphinxext/ipython_directive.py:449–610  ·  view source on GitHub ↗

Process data block for INPUT token.

(self, data, input_prompt, lineno)

Source from the content-addressed store, hash-verified

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

Callers 1

process_blockMethod · 0.95

Calls 6

process_imageMethod · 0.95
process_input_linesMethod · 0.95
clear_coutMethod · 0.95
seekMethod · 0.80
readMethod · 0.80
formatMethod · 0.45

Tested by

no test coverage detected