##// END OF EJS Templates
fix again() bug in demo
fperez -
r26:6eeb6c56
parent child
Show More
@@ -87,6 +87,7 class Demo:
87 def again(self):
87 def again(self):
88 """Repeat the last block"""
88 """Repeat the last block"""
89 self.block_index -= 1
89 self.block_index -= 1
90 self.finished = False
90 self()
91 self()
91
92
92 def _validate_index(self,index):
93 def _validate_index(self,index):
@@ -108,8 +109,8 class Demo:
108 index = self.block_index
109 index = self.block_index
109 else:
110 else:
110 self._validate_index(index)
111 self._validate_index(index)
111 print marquee('<%s> block # %s (%s/%s)' %
112 print marquee('<%s> block # %s (%s remaining)' %
112 (self.fname,index,index+1,self.nblocks))
113 (self.fname,index,self.nblocks-index-1))
113 print self.src_blocks_colored[index],
114 print self.src_blocks_colored[index],
114
115
115 def show(self):
116 def show(self):
@@ -120,11 +121,11 class Demo:
120 silent = self.silent
121 silent = self.silent
121 for index,block in enumerate(self.src_blocks_colored):
122 for index,block in enumerate(self.src_blocks_colored):
122 if silent[index]:
123 if silent[index]:
123 print marquee('<%s> SILENT block # %s (%s/%s)' %
124 print marquee('<%s> SILENT block # %s (%s remaining)' %
124 (fname,index,index+1,nblocks))
125 (fname,index,nblocks-index-1))
125 else:
126 else:
126 print marquee('<%s> block # %s (%s/%s)' %
127 print marquee('<%s> block # %s (%s remaining)' %
127 (fname,index,index+1,nblocks))
128 (fname,index,nblocks-index-1))
128 print block,
129 print block,
129
130
130 def __call__(self,index=None):
131 def __call__(self,index=None):
@@ -146,11 +147,13 class Demo:
146 next_block = self.src_blocks[index]
147 next_block = self.src_blocks[index]
147 self.block_index += 1
148 self.block_index += 1
148 if self.silent[index]:
149 if self.silent[index]:
149 print marquee('Executing silent block # %s (%s/%s)' %
150 print marquee('Executing silent block # %s (%s remaining)' %
150 (index,index+1,self.nblocks))
151 (index,self.nblocks-index-1))
151 else:
152 else:
152 self.show_block(index)
153 self.show_block(index)
153 if not self.auto:
154 if self.auto:
155 print marquee('output')
156 else:
154 print marquee('Press <q> to quit, <Enter> to execute...'),
157 print marquee('Press <q> to quit, <Enter> to execute...'),
155 ans = raw_input().strip()
158 ans = raw_input().strip()
156 if ans:
159 if ans:
@@ -1,5 +1,8
1 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
1 2005-09-22 Fernando Perez <Fernando.Perez@colorado.edu>
2
2
3 * IPython/demo.py (Demo.again): fix bug where again() blocks after
4 finishing.
5
3 * IPython/genutils.py (shlex_split): moved from Magic to here,
6 * IPython/genutils.py (shlex_split): moved from Magic to here,
4 where all 2.2 compatibility stuff lives. I needed it for demo.py.
7 where all 2.2 compatibility stuff lives. I needed it for demo.py.
5
8
General Comments 0
You need to be logged in to leave comments. Login now