##// END OF EJS Templates
implement range pattern with prints for testing
Daniel Goldfarb -
Show More
@@ -16,6 +16,7 b''
16 import os
16 import os
17 import sys
17 import sys
18 from io import open as io_open
18 from io import open as io_open
19 import fnmatch
19
20
20 # Our own packages
21 # Our own packages
21 from IPython.core.error import StdinNotImplementedError
22 from IPython.core.error import StdinNotImplementedError
@@ -170,21 +171,34 b' class HistoryMagics(Magics):'
170 pattern = None
171 pattern = None
171 limit = None if args.limit is _unspecified else args.limit
172 limit = None if args.limit is _unspecified else args.limit
172
173
173 if args.pattern is not None:
174 print('args.pattern=',args.pattern)
175 print('args.limit=',args.limit)
176 print('type(args.limit)=',type(args.limit))
177 print('args.range=',args.range)
178
179 range_pattern = False
180 if args.pattern is not None and not args.range:
174 if args.pattern:
181 if args.pattern:
175 pattern = "*" + " ".join(args.pattern) + "*"
182 pattern = "*" + " ".join(args.pattern) + "*"
176 else:
183 else:
177 pattern = "*"
184 pattern = "*"
185 print('pattern=',pattern)
178 hist = history_manager.search(pattern, raw=raw, output=get_output,
186 hist = history_manager.search(pattern, raw=raw, output=get_output,
179 n=limit, unique=args.unique)
187 n=limit, unique=args.unique)
188 print('type(hist)=',type(hist))
180 print_nums = True
189 print_nums = True
181 elif args.limit is not _unspecified:
190 elif args.limit is not _unspecified:
182 n = 10 if limit is None else limit
191 n = 10 if limit is None else limit
183 hist = history_manager.get_tail(n, raw=raw, output=get_output)
192 hist = history_manager.get_tail(n, raw=raw, output=get_output)
184 else:
193 else:
185 if args.range: # Get history by ranges
194 if args.range: # Get history by ranges
195 if args.pattern:
196 range_pattern = "*" + " ".join(args.pattern) + "*"
197 print_nums = True
198 print('range_pattern=',range_pattern)
186 hist = history_manager.get_range_by_str(" ".join(args.range),
199 hist = history_manager.get_range_by_str(" ".join(args.range),
187 raw, get_output)
200 raw, get_output)
201 print('type(hist)=',type(hist))
188 else: # Just get history for the current session
202 else: # Just get history for the current session
189 hist = history_manager.get_range(raw=raw, output=get_output)
203 hist = history_manager.get_range(raw=raw, output=get_output)
190
204
@@ -200,6 +214,8 b' class HistoryMagics(Magics):'
200 # into an editor.
214 # into an editor.
201 if get_output:
215 if get_output:
202 inline, output = inline
216 inline, output = inline
217 if range_pattern:
218 if not fnmatch.fnmatch(inline,range_pattern): continue;
203 inline = inline.expandtabs(4).rstrip()
219 inline = inline.expandtabs(4).rstrip()
204
220
205 multiline = "\n" in inline
221 multiline = "\n" in inline
General Comments 0
You need to be logged in to leave comments. Login now