Show More
@@ -221,7 +221,6 b' class Demo(object):' | |||||
221 | """ |
|
221 | """ | |
222 | if hasattr(src, "read"): |
|
222 | if hasattr(src, "read"): | |
223 | # It seems to be a file or a file-like object |
|
223 | # It seems to be a file or a file-like object | |
224 | self.fobj = src |
|
|||
225 | self.fname = "from a file-like object" |
|
224 | self.fname = "from a file-like object" | |
226 | if title == '': |
|
225 | if title == '': | |
227 | self.title = "from a file-like object" |
|
226 | self.title = "from a file-like object" | |
@@ -229,7 +228,6 b' class Demo(object):' | |||||
229 | self.title = title |
|
228 | self.title = title | |
230 | else: |
|
229 | else: | |
231 | # Assume it's a string or something that can be converted to one |
|
230 | # Assume it's a string or something that can be converted to one | |
232 | self.fobj = open(src) |
|
|||
233 | self.fname = src |
|
231 | self.fname = src | |
234 | if title == '': |
|
232 | if title == '': | |
235 | (filepath, filename) = os.path.split(src) |
|
233 | (filepath, filename) = os.path.split(src) | |
@@ -238,6 +236,7 b' class Demo(object):' | |||||
238 | self.title = title |
|
236 | self.title = title | |
239 | self.sys_argv = [src] + shlex.split(arg_str) |
|
237 | self.sys_argv = [src] + shlex.split(arg_str) | |
240 | self.auto_all = auto_all |
|
238 | self.auto_all = auto_all | |
|
239 | self.src = src | |||
241 |
|
240 | |||
242 | # get a few things from ipython. While it's a bit ugly design-wise, |
|
241 | # get a few things from ipython. While it's a bit ugly design-wise, | |
243 | # it ensures that things like color scheme and the like are always in |
|
242 | # it ensures that things like color scheme and the like are always in | |
@@ -255,6 +254,15 b' class Demo(object):' | |||||
255 | def reload(self): |
|
254 | def reload(self): | |
256 | """Reload source from disk and initialize state.""" |
|
255 | """Reload source from disk and initialize state.""" | |
257 | # read data and parse into blocks |
|
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 | self.src = self.fobj.read() |
|
266 | self.src = self.fobj.read() | |
259 | src_b = [b.strip() for b in self.re_stop.split(self.src) if b] |
|
267 | src_b = [b.strip() for b in self.re_stop.split(self.src) if b] | |
260 | self._silent = [bool(self.re_silent.findall(b)) for b in src_b] |
|
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