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