Show More
@@ -21,7 +21,7 b' from IPython.external.argparse import Action' | |||
|
21 | 21 | # Our own packages |
|
22 | 22 | from IPython.core.error import StdinNotImplementedError |
|
23 | 23 | from IPython.core.magic import Magics, magics_class, line_magic |
|
24 |
from IPython.core.magic_arguments import (argument, |
|
|
24 | from IPython.core.magic_arguments import (argument, magic_arguments, | |
|
25 | 25 | parse_argstring) |
|
26 | 26 | from IPython.testing.skipdoctest import skip_doctest |
|
27 | 27 | from IPython.utils import io |
@@ -31,10 +31,7 b' from IPython.utils import io' | |||
|
31 | 31 | #----------------------------------------------------------------------------- |
|
32 | 32 | |
|
33 | 33 | |
|
34 | class HistoryArgLimitAction(Action): | |
|
35 | def __call__(self, parser, namespace, values, option_string=None): | |
|
36 | namespace.limit_specified = True | |
|
37 | namespace.limit = values | |
|
34 | _unspecified = object() | |
|
38 | 35 | |
|
39 | 36 | |
|
40 | 37 | @magics_class |
@@ -87,13 +84,12 b' class HistoryMagics(Magics):' | |||
|
87 | 84 | full saved history (may be very long). |
|
88 | 85 | """) |
|
89 | 86 | @argument( |
|
90 |
'-l', dest='limit', type=int, nargs='?', |
|
|
87 | '-l', dest='limit', type=int, nargs='?', default=_unspecified, | |
|
91 | 88 | help=""" |
|
92 | 89 | get the last n lines from all sessions. Specify n as a single |
|
93 | 90 | arg, or the default is the last 10 lines. |
|
94 | 91 | """) |
|
95 | 92 | @argument('range', nargs='*') |
|
96 | @defaults(limit_specified=False) | |
|
97 | 93 | @skip_doctest |
|
98 | 94 | @line_magic |
|
99 | 95 | def history(self, parameter_s = ''): |
@@ -165,6 +161,7 b' class HistoryMagics(Magics):' | |||
|
165 | 161 | raw = args.raw |
|
166 | 162 | |
|
167 | 163 | pattern = None |
|
164 | limit = None if args.limit is _unspecified else args.limit | |
|
168 | 165 | |
|
169 | 166 | if args.pattern is not None: |
|
170 | 167 | if args.pattern: |
@@ -172,10 +169,10 b' class HistoryMagics(Magics):' | |||
|
172 | 169 | else: |
|
173 | 170 | pattern = "*" |
|
174 | 171 | hist = history_manager.search(pattern, raw=raw, output=get_output, |
|
175 |
n= |
|
|
172 | n=limit) | |
|
176 | 173 | print_nums = True |
|
177 | elif args.limit_specified: | |
|
178 |
n = 10 if |
|
|
174 | elif args.limit is not _unspecified: | |
|
175 | n = 10 if limit is None else limit | |
|
179 | 176 | hist = history_manager.get_tail(n, raw=raw, output=get_output) |
|
180 | 177 | else: |
|
181 | 178 | if args.range: # Get history by ranges |
General Comments 0
You need to be logged in to leave comments.
Login now