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

Method reload

IPython/lib/demo.py:301–335  ·  view source on GitHub ↗

Reload source from disk and initialize state.

(self)

Source from the content-addressed store, hash-verified

299 self.fobj = openpy.open(self.fname)
300
301 def reload(self):
302 """Reload source from disk and initialize state."""
303 self.fload()
304
305 self.src = "".join(openpy.strip_encoding_cookie(self.fobj))
306 src_b = [b.strip() for b in self.re_stop.split(self.src) if b]
307 self._silent = [bool(self.re_silent.findall(b)) for b in src_b]
308 self._auto = [bool(self.re_auto.findall(b)) for b in src_b]
309
310 # if auto_all is not given (def. None), we read it from the file
311 if self.auto_all is None:
312 self.auto_all = bool(self.re_auto_all.findall(src_b[0]))
313 else:
314 self.auto_all = bool(self.auto_all)
315
316 # Clean the sources from all markup so it doesn't get displayed when
317 # running the demo
318 src_blocks = []
319 auto_strip = lambda s: self.re_auto.sub('',s)
320 for i,b in enumerate(src_b):
321 if self._auto[i]:
322 src_blocks.append(auto_strip(b))
323 else:
324 src_blocks.append(b)
325 # remove the auto_all marker
326 src_blocks[0] = self.re_auto_all.sub('',src_blocks[0])
327
328 self.nblocks = len(src_blocks)
329 self.src_blocks = src_blocks
330
331 # also build syntax-highlighted source
332 self.src_blocks_colored = list(map(self.highlight,self.src_blocks))
333
334 # ensure clean namespace and seek offset
335 self.reset()
336
337 def reset(self):
338 """Reset the namespace and seek pointer to restart the demo"""

Callers 3

__init__Method · 0.95
import_submoduleFunction · 0.45
deep_reload_hookFunction · 0.45

Calls 2

floadMethod · 0.95
resetMethod · 0.95

Tested by

no test coverage detected