Show More
@@ -8,6 +8,7 b' import os' | |||||
8 |
|
8 | |||
9 | # IPython imports |
|
9 | # IPython imports | |
10 | from IPython.genutils import Term, ask_yes_no |
|
10 | from IPython.genutils import Term, ask_yes_no | |
|
11 | import IPython.ipapi | |||
11 |
|
12 | |||
12 | def magic_history(self, parameter_s = ''): |
|
13 | def magic_history(self, parameter_s = ''): | |
13 | """Print input history (_i<n> variables), with most recent last. |
|
14 | """Print input history (_i<n> variables), with most recent last. | |
@@ -222,6 +223,7 b' class ShadowHist:' | |||||
222 | # cmd => idx mapping |
|
223 | # cmd => idx mapping | |
223 | self.curidx = 0 |
|
224 | self.curidx = 0 | |
224 | self.db = db |
|
225 | self.db = db | |
|
226 | self.disabled = False | |||
225 |
|
227 | |||
226 | def inc_idx(self): |
|
228 | def inc_idx(self): | |
227 | idx = self.db.get('shadowhist_idx', 1) |
|
229 | idx = self.db.get('shadowhist_idx', 1) | |
@@ -229,12 +231,19 b' class ShadowHist:' | |||||
229 | return idx |
|
231 | return idx | |
230 |
|
232 | |||
231 | def add(self, ent): |
|
233 | def add(self, ent): | |
232 | old = self.db.hget('shadowhist', ent, _sentinel) |
|
234 | if self.disabled: | |
233 | if old is not _sentinel: |
|
|||
234 | return |
|
235 | return | |
235 | newidx = self.inc_idx() |
|
236 | try: | |
236 | #print "new",newidx # dbg |
|
237 | old = self.db.hget('shadowhist', ent, _sentinel) | |
237 | self.db.hset('shadowhist',ent, newidx) |
|
238 | if old is not _sentinel: | |
|
239 | return | |||
|
240 | newidx = self.inc_idx() | |||
|
241 | #print "new",newidx # dbg | |||
|
242 | self.db.hset('shadowhist',ent, newidx) | |||
|
243 | except: | |||
|
244 | IPython.ipapi.get().IP.showtraceback() | |||
|
245 | print "WARNING: disabling shadow history" | |||
|
246 | self.disabled = True | |||
238 |
|
247 | |||
239 | def all(self): |
|
248 | def all(self): | |
240 | d = self.db.hdict('shadowhist') |
|
249 | d = self.db.hdict('shadowhist') |
General Comments 0
You need to be logged in to leave comments.
Login now