##// END OF EJS Templates
Fix %history to stop printing last line....
Fernando Perez -
Show More
@@ -91,7 +91,7 b" def magic_history(self, parameter_s = ''):"
91 head, pattern = parts
91 head, pattern = parts
92 pattern = "*" + pattern + "*"
92 pattern = "*" + pattern + "*"
93 elif len(args) == 0:
93 elif len(args) == 0:
94 final = len(input_hist)
94 final = len(input_hist)-1
95 init = max(1,final-default_length)
95 init = max(1,final-default_length)
96 elif len(args) == 1:
96 elif len(args) == 1:
97 final = len(input_hist)
97 final = len(input_hist)
@@ -100,7 +100,7 b" def magic_history(self, parameter_s = ''):"
100 init,final = map(int,args)
100 init, final = map(int, args)
101 else:
101 else:
102 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
102 warn('%hist takes 0, 1 or 2 arguments separated by spaces.')
103 print self.magic_hist.__doc__
103 print >> Term.cout, self.magic_hist.__doc__
104 return
104 return
105
105
106 width = len(str(final))
106 width = len(str(final))
@@ -114,13 +114,14 b" def magic_history(self, parameter_s = ''):"
114 sh = self.shadowhist.all()
114 sh = self.shadowhist.all()
115 for idx, s in sh:
115 for idx, s in sh:
116 if fnmatch.fnmatch(s, pattern):
116 if fnmatch.fnmatch(s, pattern):
117 print "0%d: %s" %(idx, s)
117 print >> outfile, "0%d: %s" %(idx, s)
118 found = True
118 found = True
119
119
120 if found:
120 if found:
121 print "==="
121 print >> outfile, "==="
122 print "shadow history ends, fetch by %rep <number> (must start with 0)"
122 print >> outfile, \
123 print "=== start of normal history ==="
123 "shadow history ends, fetch by %rep <number> (must start with 0)"
124 print >> outfile, "=== start of normal history ==="
124
125
125 for in_num in range(init,final):
126 for in_num in range(init,final):
126 inline = input_hist[in_num]
127 inline = input_hist[in_num]
@@ -141,9 +142,10 b" def magic_history(self, parameter_s = ''):"
141 print >> outfile, inline,
142 print >> outfile, inline,
142 else:
143 else:
143 print >> outfile, inline,
144 print >> outfile, inline,
145 if print_outputs:
144 output = self.shell.user_ns['Out'].get(in_num)
146 output = self.shell.user_ns['Out'].get(in_num)
145 if output is not None:
147 if output is not None:
146 print repr(output)
148 print >> outfile, repr(output)
147
149
148 if close_at_end:
150 if close_at_end:
149 outfile.close()
151 outfile.close()
@@ -153,7 +153,6 b' def doctest_hist_op():'
153 >>> ss
153 >>> ss
154 <...s instance at ...>
154 <...s instance at ...>
155 >>>
155 >>>
156 >>> get_ipython().magic("hist -op")
157 """
156 """
158
157
159 def test_shist():
158 def test_shist():
General Comments 0
You need to be logged in to leave comments. Login now