Changeset 2992
- Timestamp:
- 01/29/08 01:42:03 (10 months ago)
- Files:
-
- ipython/trunk/IPython/history.py (modified) (4 diffs)
- ipython/trunk/doc/ChangeLog (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
ipython/trunk/IPython/history.py
r2740 r2992 3 3 """ History related magics and functionality """ 4 4 5 # Stdlib imports 5 6 import fnmatch 7 import os 8 9 # IPython imports 10 from IPython.genutils import Term, ask_yes_no 6 11 7 12 def magic_history(self, parameter_s = ''): … … 47 52 print 'This feature is only available if numbered prompts are in use.' 48 53 return 49 opts,args = self.parse_options(parameter_s,'gntsr',mode='list') 54 opts,args = self.parse_options(parameter_s,'gntsrf:',mode='list') 55 56 # Check if output to specific file was requested. 57 try: 58 outfname = opts['f'] 59 except KeyError: 60 outfile = Term.cout 61 # We don't want to close stdout at the end! 62 close_at_end = False 63 else: 64 if os.path.exists(outfname): 65 ans = ask_yes_no("File %r exists. Overwrite?" % outfname) 66 if not ans: 67 print 'Aborting.' 68 return 69 else: 70 outfile = open(outfname,'w') 71 close_at_end = True 72 50 73 51 74 if opts.has_key('t'): … … 93 116 if found: 94 117 print "===" 95 print " ^shadow history ends, fetch by %rep <number> (must start with 0)"118 print "shadow history ends, fetch by %rep <number> (must start with 0)" 96 119 print "=== start of normal history ===" 97 120 … … 103 126 multiline = int(inline.count('\n') > 1) 104 127 if print_nums: 105 print '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]), 106 print inline, 128 print >> outfile, \ 129 '%s:%s' % (str(in_num).ljust(width),line_sep[multiline]), 130 print >> outfile, inline, 131 132 if close_at_end: 133 outfile.close() 107 134 108 135 ipython/trunk/doc/ChangeLog
r2965 r2992 1 2008-01-29 Fernando Perez <Fernando.Perez@colorado.edu> 2 3 * IPython/history.py (magic_history): Add support for declaring an 4 output file directly from the history command. 5 1 6 2008-01-21 Walter Doerwald <walter@livinglogic.de> 2 7
