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

Method _run_cmd_line_code

IPython/core/shellapp.py:458–487  ·  view source on GitHub ↗

Run code or file specified at the command-line

(self)

Source from the content-addressed store, hash-verified

456 self.shell.showtraceback()
457
458 def _run_cmd_line_code(self):
459 """Run code or file specified at the command-line"""
460 if self.code_to_run:
461 line = self.code_to_run
462 try:
463 self.log.info("Running code given at command line (c=): %s" %
464 line)
465 self.shell.run_cell(line, store_history=False)
466 except:
467 self.log.warning("Error in executing line in user namespace: %s" %
468 line)
469 self.shell.showtraceback()
470 if not self.interact:
471 self.exit(1)
472
473 # Like Python itself, ignore the second if the first of these is present
474 elif self.file_to_run:
475 fname = self.file_to_run
476 if os.path.isdir(fname):
477 fname = os.path.join(fname, "__main__.py")
478 if not os.path.exists(fname):
479 self.log.warning("File '%s' doesn't exist", fname)
480 if not self.interact:
481 self.exit(2)
482 try:
483 self._exec_file(fname, shell_futures=True)
484 except:
485 self.shell.showtraceback(tb_offset=4)
486 if not self.interact:
487 self.exit(1)
488
489 def _run_module(self):
490 """Run module specified at the command-line."""

Callers 1

init_codeMethod · 0.95

Calls 4

_exec_fileMethod · 0.95
infoMethod · 0.80
run_cellMethod · 0.45
showtracebackMethod · 0.45

Tested by

no test coverage detected