##// END OF EJS Templates
Fix broken demo reload()....
Fernando Perez -
Show More
@@ -221,7 +221,6 b' class Demo(object):'
221 221 """
222 222 if hasattr(src, "read"):
223 223 # It seems to be a file or a file-like object
224 self.fobj = src
225 224 self.fname = "from a file-like object"
226 225 if title == '':
227 226 self.title = "from a file-like object"
@@ -229,7 +228,6 b' class Demo(object):'
229 228 self.title = title
230 229 else:
231 230 # Assume it's a string or something that can be converted to one
232 self.fobj = open(src)
233 231 self.fname = src
234 232 if title == '':
235 233 (filepath, filename) = os.path.split(src)
@@ -238,6 +236,7 b' class Demo(object):'
238 236 self.title = title
239 237 self.sys_argv = [src] + shlex.split(arg_str)
240 238 self.auto_all = auto_all
239 self.src = src
241 240
242 241 # get a few things from ipython. While it's a bit ugly design-wise,
243 242 # it ensures that things like color scheme and the like are always in
@@ -255,6 +254,15 b' class Demo(object):'
255 254 def reload(self):
256 255 """Reload source from disk and initialize state."""
257 256 # read data and parse into blocks
257 if hasattr(self, 'fobj') and self.fobj is not None:
258 self.fobj.close()
259 if hasattr(self.src, "read"):
260 # It seems to be a file or a file-like object
261 self.fobj = self.src
262 else:
263 # Assume it's a string or something that can be converted to one
264 self.fobj = open(self.fname)
265
258 266 self.src = self.fobj.read()
259 267 src_b = [b.strip() for b in self.re_stop.split(self.src) if b]
260 268 self._silent = [bool(self.re_silent.findall(b)) for b in src_b]
General Comments 0
You need to be logged in to leave comments. Login now