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