MCPcopy Create free account
hub / github.com/ipython/ipython / InteractiveShellEmbed

Class InteractiveShellEmbed

IPython/terminal/embed.py:110–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108
109
110class InteractiveShellEmbed(TerminalInteractiveShell):
111
112 dummy_mode = Bool(False)
113 exit_msg = Unicode('')
114 embedded = CBool(True)
115 should_raise = CBool(False)
116 # Like the base class display_banner is not configurable, but here it
117 # is True by default.
118 display_banner = CBool(True)
119 exit_msg = Unicode()
120
121 # When embedding, by default we don't change the terminal title
122 term_title = Bool(False,
123 help="Automatically set the terminal title"
124 ).tag(config=True)
125
126 _inactive_locations = set()
127
128 @property
129 def embedded_active(self):
130 return (self._call_location_id not in InteractiveShellEmbed._inactive_locations)\
131 and (self._init_location_id not in InteractiveShellEmbed._inactive_locations)
132
133 def _disable_init_location(self):
134 """Disable the current Instance creation location"""
135 InteractiveShellEmbed._inactive_locations.add(self._init_location_id)
136
137 @embedded_active.setter
138 def embedded_active(self, value):
139 if value:
140 InteractiveShellEmbed._inactive_locations.discard(
141 self._call_location_id)
142 InteractiveShellEmbed._inactive_locations.discard(
143 self._init_location_id)
144 else:
145 InteractiveShellEmbed._inactive_locations.add(
146 self._call_location_id)
147
148 def __init__(self, **kw):
149 if kw.get('user_global_ns', None) is not None:
150 raise DeprecationWarning(
151 "Key word argument `user_global_ns` has been replaced by `user_module` since IPython 4.0.")
152
153 clid = kw.pop('_init_location_id', None)
154 if not clid:
155 frame = sys._getframe(1)
156 clid = '%s:%s' % (frame.f_code.co_filename, frame.f_lineno)
157 self._init_location_id = clid
158
159 super(InteractiveShellEmbed,self).__init__(**kw)
160
161 # don't use the ipython crash handler so that user exceptions aren't
162 # trapped
163 sys.excepthook = ultratb.FormattedTB(color_scheme=self.colors,
164 mode=self.xmode,
165 call_pdb=self.pdb)
166
167 def init_sys_modules(self):

Callers 3

embed3.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected