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

Method setup

IPython/sphinxext/ipython_directive.py:945–996  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

943 promptin, promptout, mplbackend, exec_lines, hold_count, warning_is_error)
944
945 def setup(self):
946 # Get configuration values.
947 (savefig_dir, source_dir, rgxin, rgxout, promptin, promptout,
948 mplbackend, exec_lines, hold_count, warning_is_error) = self.get_config_options()
949
950 try:
951 os.makedirs(savefig_dir)
952 except OSError as e:
953 if e.errno != errno.EEXIST:
954 raise
955
956 if self.shell is None:
957 # We will be here many times. However, when the
958 # EmbeddedSphinxShell is created, its interactive shell member
959 # is the same for each instance.
960
961 if mplbackend and 'matplotlib.backends' not in sys.modules and use_matplotlib:
962 import matplotlib
963 matplotlib.use(mplbackend)
964
965 # Must be called after (potentially) importing matplotlib and
966 # setting its backend since exec_lines might import pylab.
967 self.shell = EmbeddedSphinxShell(exec_lines)
968
969 # Store IPython directive to enable better error messages
970 self.shell.directive = self
971
972 # reset the execution count if we haven't processed this doc
973 #NOTE: this may be borked if there are multiple seen_doc tmp files
974 #check time stamp?
975 if self.state.document.current_source not in self.seen_docs:
976 self.shell.IP.history_manager.reset()
977 self.shell.IP.execution_count = 1
978 self.seen_docs.add(self.state.document.current_source)
979
980 # and attach to shell so we don't have to pass them around
981 self.shell.rgxin = rgxin
982 self.shell.rgxout = rgxout
983 self.shell.promptin = promptin
984 self.shell.promptout = promptout
985 self.shell.savefig_dir = savefig_dir
986 self.shell.source_dir = source_dir
987 self.shell.hold_count = hold_count
988 self.shell.warning_is_error = warning_is_error
989
990 # setup bookmark for saving figures directory
991 self.shell.process_input_line(
992 'bookmark ipy_savedir "%s"' % savefig_dir, store_history=False
993 )
994 self.shell.clear_cout()
995
996 return rgxin, rgxout, promptin, promptout
997
998 def teardown(self):
999 # delete last bookmark

Callers 2

runMethod · 0.95
do_exceptionsMethod · 0.45

Calls 6

get_config_optionsMethod · 0.95
EmbeddedSphinxShellClass · 0.85
process_input_lineMethod · 0.80
clear_coutMethod · 0.80
resetMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected