Show More
@@ -253,8 +253,8 b' class Demo(object):' | |||
|
253 | 253 | # load user data and initialize data structures |
|
254 | 254 | self.reload() |
|
255 | 255 | |
|
256 |
def |
|
|
257 | """Reload source from disk and initialize state.""" | |
|
256 | def fload(self): | |
|
257 | """Load file object.""" | |
|
258 | 258 | # read data and parse into blocks |
|
259 | 259 | if hasattr(self, 'fobj') and self.fobj is not None: |
|
260 | 260 | self.fobj.close() |
@@ -265,6 +265,10 b' class Demo(object):' | |||
|
265 | 265 | # Assume it's a string or something that can be converted to one |
|
266 | 266 | self.fobj = open(self.fname) |
|
267 | 267 | |
|
268 | def reload(self): | |
|
269 | """Reload source from disk and initialize state.""" | |
|
270 | self.fload() | |
|
271 | ||
|
268 | 272 | self.src = self.fobj.read() |
|
269 | 273 | src_b = [b.strip() for b in self.re_stop.split(self.src) if b] |
|
270 | 274 | self._silent = [bool(self.re_silent.findall(b)) for b in src_b] |
@@ -504,14 +508,20 b' class LineDemo(Demo):' | |||
|
504 | 508 | This class doesn't require any markup at all, and it's meant for simple |
|
505 | 509 | scripts (with no nesting or any kind of indentation) which consist of |
|
506 | 510 | multiple lines of input to be executed, one at a time, as if they had been |
|
507 |
typed in the interactive prompt. |
|
|
511 | typed in the interactive prompt. | |
|
512 | ||
|
513 | Note: the input can not have *any* indentation, which means that only | |
|
514 | single-lines of input are accepted, not even function definitions are | |
|
515 | valid.""" | |
|
508 | 516 | |
|
509 | 517 | def reload(self): |
|
510 | 518 | """Reload source from disk and initialize state.""" |
|
511 | 519 | # read data and parse into blocks |
|
512 | src_b = [l for l in self.fobj.readline() if l.strip()] | |
|
520 | self.fload() | |
|
521 | lines = self.fobj.readlines() | |
|
522 | src_b = [l for l in lines if l.strip()] | |
|
513 | 523 | nblocks = len(src_b) |
|
514 |
self.src = |
|
|
524 | self.src = ''.join(lines) | |
|
515 | 525 | self._silent = [False]*nblocks |
|
516 | 526 | self._auto = [True]*nblocks |
|
517 | 527 | self.auto_all = True |
General Comments 0
You need to be logged in to leave comments.
Login now