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