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