Show More
@@ -32,25 +32,21 b' This is an handy alias to `ipython history trim --keep=0`' | |||||
32 |
|
32 | |||
33 | class HistoryTrim(BaseIPythonApplication): |
|
33 | class HistoryTrim(BaseIPythonApplication): | |
34 | description = trim_hist_help |
|
34 | description = trim_hist_help | |
35 |
|
||||
36 | backup = Bool(False, |
|
|||
37 | help="Keep the old history file as history.sqlite.<N>" |
|
|||
38 | ).tag(config=True) |
|
|||
39 |
|
||||
40 | keep = Int(1000, |
|
|||
41 | help="Number of recent lines to keep in the database." |
|
|||
42 | ).tag(config=True) |
|
|||
43 |
|
||||
44 | flags = Dict(dict( |
|
|||
45 | backup = ({'HistoryTrim' : {'backup' : True}}, |
|
|||
46 | backup.help |
|
|||
47 | ) |
|
|||
48 | )) |
|
|||
49 |
|
35 | |||
50 | aliases=Dict(dict( |
|
36 | backup = Bool(False, help="Keep the old history file as history.sqlite.<N>").tag( | |
51 | keep = 'HistoryTrim.keep' |
|
37 | config=True | |
52 |
) |
|
38 | ) | |
53 |
|
39 | |||
|
40 | keep = Int(1000, help="Number of recent lines to keep in the database.").tag( | |||
|
41 | config=True | |||
|
42 | ) | |||
|
43 | ||||
|
44 | flags = Dict( # type: ignore | |||
|
45 | dict(backup=({"HistoryTrim": {"backup": True}}, backup.help)) | |||
|
46 | ) | |||
|
47 | ||||
|
48 | aliases = Dict(dict(keep="HistoryTrim.keep")) # type: ignore | |||
|
49 | ||||
54 | def start(self): |
|
50 | def start(self): | |
55 | profile_dir = Path(self.profile_dir.location) |
|
51 | profile_dir = Path(self.profile_dir.location) | |
56 | hist_file = profile_dir / "history.sqlite" |
|
52 | hist_file = profile_dir / "history.sqlite" | |
@@ -114,34 +110,33 b' class HistoryTrim(BaseIPythonApplication):' | |||||
114 | print("Backed up longer history file to", backup_hist_file) |
|
110 | print("Backed up longer history file to", backup_hist_file) | |
115 | else: |
|
111 | else: | |
116 | hist_file.unlink() |
|
112 | hist_file.unlink() | |
117 |
|
113 | |||
118 | new_hist_file.rename(hist_file) |
|
114 | new_hist_file.rename(hist_file) | |
119 |
|
115 | |||
|
116 | ||||
120 | class HistoryClear(HistoryTrim): |
|
117 | class HistoryClear(HistoryTrim): | |
121 | description = clear_hist_help |
|
118 | description = clear_hist_help | |
122 | keep = Int(0, |
|
119 | keep = Int(0, help="Number of recent lines to keep in the database.") | |
123 | help="Number of recent lines to keep in the database.") |
|
120 | ||
124 |
|
121 | force = Bool(False, help="Don't prompt user for confirmation").tag(config=True) | ||
125 | force = Bool(False, |
|
122 | ||
126 | help="Don't prompt user for confirmation" |
|
123 | flags = Dict( # type: ignore | |
127 | ).tag(config=True) |
|
124 | dict( | |
128 |
|
125 | force=({"HistoryClear": {"force": True}}, force.help), | ||
129 | flags = Dict(dict( |
|
126 | f=({"HistoryTrim": {"force": True}}, force.help), | |
130 | force = ({'HistoryClear' : {'force' : True}}, |
|
|||
131 | force.help), |
|
|||
132 | f = ({'HistoryTrim' : {'force' : True}}, |
|
|||
133 | force.help |
|
|||
134 | ) |
|
127 | ) | |
135 |
) |
|
128 | ) | |
136 | aliases = Dict() |
|
129 | aliases = Dict() # type: ignore | |
137 |
|
130 | |||
138 | def start(self): |
|
131 | def start(self): | |
139 |
if self.force or ask_yes_no( |
|
132 | if self.force or ask_yes_no( | |
140 |
default="no", interrupt="no" |
|
133 | "Really delete all ipython history? ", default="no", interrupt="no" | |
|
134 | ): | |||
141 | HistoryTrim.start(self) |
|
135 | HistoryTrim.start(self) | |
142 |
|
136 | |||
|
137 | ||||
143 | class HistoryApp(Application): |
|
138 | class HistoryApp(Application): | |
144 |
name = |
|
139 | name = "ipython-history" | |
145 | description = "Manage the IPython history database." |
|
140 | description = "Manage the IPython history database." | |
146 |
|
141 | |||
147 | subcommands = Dict(dict( |
|
142 | subcommands = Dict(dict( |
@@ -19,7 +19,6 b' exclude = [' | |||||
19 | 'IPython/core/application.py', |
|
19 | 'IPython/core/application.py', | |
20 | 'IPython/core/completerlib.py', |
|
20 | 'IPython/core/completerlib.py', | |
21 | 'IPython/core/displaypub.py', |
|
21 | 'IPython/core/displaypub.py', | |
22 | 'IPython/core/historyapp.py', |
|
|||
23 | #'IPython/core/interactiveshell.py', |
|
22 | #'IPython/core/interactiveshell.py', | |
24 | 'IPython/core/magic.py', |
|
23 | 'IPython/core/magic.py', | |
25 | 'IPython/core/profileapp.py', |
|
24 | 'IPython/core/profileapp.py', | |
@@ -30,8 +29,6 b' exclude = [' | |||||
30 | 'IPython/terminal/ipapp.py', |
|
29 | 'IPython/terminal/ipapp.py', | |
31 | 'IPython/utils/_process_win32.py', |
|
30 | 'IPython/utils/_process_win32.py', | |
32 | 'IPython/utils/path.py', |
|
31 | 'IPython/utils/path.py', | |
33 | 'IPython/utils/timing.py', |
|
|||
34 | 'IPython/utils/text.py' |
|
|||
35 | ] |
|
32 | ] | |
36 |
|
33 | |||
37 | [tool.pytest.ini_options] |
|
34 | [tool.pytest.ini_options] |
General Comments 0
You need to be logged in to leave comments.
Login now