Show More
@@ -29,6 +29,7 b' import threading' | |||
|
29 | 29 | # Our own packages |
|
30 | 30 | from IPython.config.configurable import Configurable |
|
31 | 31 | from IPython.external.decorator import decorator |
|
32 | from IPython.utils.decorators import undoc | |
|
32 | 33 | from IPython.utils.path import locate_profile |
|
33 | 34 | from IPython.utils import py3compat |
|
34 | 35 | from IPython.utils.traitlets import ( |
@@ -40,6 +41,7 b' from IPython.utils.warn import warn' | |||
|
40 | 41 | # Classes and functions |
|
41 | 42 | #----------------------------------------------------------------------------- |
|
42 | 43 | |
|
44 | @undoc | |
|
43 | 45 | class DummyDB(object): |
|
44 | 46 | """Dummy DB that will act as a black hole for history. |
|
45 | 47 | |
@@ -59,7 +61,7 b' class DummyDB(object):' | |||
|
59 | 61 | |
|
60 | 62 | @decorator |
|
61 | 63 | def needs_sqlite(f, self, *a, **kw): |
|
62 | """return an empty list in the absence of sqlite""" | |
|
64 | """Decorator: return an empty list in the absence of sqlite.""" | |
|
63 | 65 | if sqlite3 is None or not self.enabled: |
|
64 | 66 | return [] |
|
65 | 67 | else: |
@@ -69,6 +71,7 b' def needs_sqlite(f, self, *a, **kw):' | |||
|
69 | 71 | if sqlite3 is not None: |
|
70 | 72 | DatabaseError = sqlite3.DatabaseError |
|
71 | 73 | else: |
|
74 | @undoc | |
|
72 | 75 | class DatabaseError(Exception): |
|
73 | 76 | "Dummy exception when sqlite could not be imported. Should never occur." |
|
74 | 77 | |
@@ -159,7 +162,7 b' class HistoryAccessor(Configurable):' | |||
|
159 | 162 | hist_file : str |
|
160 | 163 | Path to an SQLite history database stored by IPython. If specified, |
|
161 | 164 | hist_file overrides profile. |
|
162 | config : | |
|
165 | config : :class:`~IPython.config.loader.Config` | |
|
163 | 166 | Config object. hist_file can also be set through this. |
|
164 | 167 | """ |
|
165 | 168 | # We need a pointer back to the shell for various tasks. |
@@ -254,8 +257,8 b' class HistoryAccessor(Configurable):' | |||
|
254 | 257 | |
|
255 | 258 | @needs_sqlite |
|
256 | 259 | @catch_corrupt_db |
|
257 |
def get_session_info(self, session |
|
|
258 |
""" |
|
|
260 | def get_session_info(self, session): | |
|
261 | """Get info about a session. | |
|
259 | 262 | |
|
260 | 263 | Parameters |
|
261 | 264 | ---------- |
@@ -268,13 +271,13 b' class HistoryAccessor(Configurable):' | |||
|
268 | 271 | |
|
269 | 272 | session_id : int |
|
270 | 273 | Session ID number |
|
271 |
|
|
|
274 | start : datetime | |
|
272 | 275 | Timestamp for the start of the session. |
|
273 |
|
|
|
276 | end : datetime | |
|
274 | 277 | Timestamp for the end of the session, or None if IPython crashed. |
|
275 |
|
|
|
278 | num_cmds : int | |
|
276 | 279 | Number of commands run, or None if IPython crashed. |
|
277 |
|
|
|
280 | remark : unicode | |
|
278 | 281 | A manually set description. |
|
279 | 282 | """ |
|
280 | 283 | query = "SELECT * from sessions where session == ?" |
@@ -383,9 +386,10 b' class HistoryAccessor(Configurable):' | |||
|
383 | 386 | |
|
384 | 387 | Returns |
|
385 | 388 | ------- |
|
386 | An iterator over the desired lines. Each line is a 3-tuple, either | |
|
387 | (session, line, input) if output is False, or | |
|
388 |
(session, line, |
|
|
389 | entries | |
|
390 | An iterator over the desired lines. Each line is a 3-tuple, either | |
|
391 | (session, line, input) if output is False, or | |
|
392 | (session, line, (input, output)) if output is True. | |
|
389 | 393 | """ |
|
390 | 394 | if stop: |
|
391 | 395 | lineclause = "line >= ? AND line < ?" |
@@ -545,27 +549,27 b' class HistoryManager(HistoryAccessor):' | |||
|
545 | 549 | # Methods for retrieving history |
|
546 | 550 | # ------------------------------ |
|
547 | 551 | def get_session_info(self, session=0): |
|
548 |
""" |
|
|
552 | """Get info about a session. | |
|
549 | 553 | |
|
550 | 554 | Parameters |
|
551 | 555 | ---------- |
|
552 | 556 | |
|
553 | 557 | session : int |
|
554 | 558 | Session number to retrieve. The current session is 0, and negative |
|
555 | numbers count back from current session, so -1 is previous session. | |
|
559 | numbers count back from current session, so -1 is the previous session. | |
|
556 | 560 | |
|
557 | 561 | Returns |
|
558 | 562 | ------- |
|
559 | 563 | |
|
560 | 564 | session_id : int |
|
561 | 565 | Session ID number |
|
562 |
|
|
|
566 | start : datetime | |
|
563 | 567 | Timestamp for the start of the session. |
|
564 |
|
|
|
568 | end : datetime | |
|
565 | 569 | Timestamp for the end of the session, or None if IPython crashed. |
|
566 |
|
|
|
570 | num_cmds : int | |
|
567 | 571 | Number of commands run, or None if IPython crashed. |
|
568 |
|
|
|
572 | remark : unicode | |
|
569 | 573 | A manually set description. |
|
570 | 574 | """ |
|
571 | 575 | if session <= 0: |
@@ -616,9 +620,10 b' class HistoryManager(HistoryAccessor):' | |||
|
616 | 620 | |
|
617 | 621 | Returns |
|
618 | 622 | ------- |
|
619 | An iterator over the desired lines. Each line is a 3-tuple, either | |
|
620 | (session, line, input) if output is False, or | |
|
621 |
(session, line, |
|
|
623 | entries | |
|
624 | An iterator over the desired lines. Each line is a 3-tuple, either | |
|
625 | (session, line, input) if output is False, or | |
|
626 | (session, line, (input, output)) if output is True. | |
|
622 | 627 | """ |
|
623 | 628 | if session <= 0: |
|
624 | 629 | session += self.session_number |
@@ -632,7 +637,7 b' class HistoryManager(HistoryAccessor):' | |||
|
632 | 637 | ## ---------------------------- |
|
633 | 638 | def store_inputs(self, line_num, source, source_raw=None): |
|
634 | 639 | """Store source and raw input in history and create input cache |
|
635 | variables _i*. | |
|
640 | variables ``_i*``. | |
|
636 | 641 | |
|
637 | 642 | Parameters |
|
638 | 643 | ---------- |
@@ -803,7 +808,7 b' def extract_hist_ranges(ranges_str):' | |||
|
803 | 808 | |
|
804 | 809 | Examples |
|
805 | 810 | -------- |
|
806 | list(extract_input_ranges("~8/5-~7/4 2")) | |
|
811 | >>> list(extract_input_ranges("~8/5-~7/4 2")) | |
|
807 | 812 | [(-8, 5, None), (-7, 1, 4), (0, 2, 3)] |
|
808 | 813 | """ |
|
809 | 814 | for range_str in ranges_str.split(): |
General Comments 0
You need to be logged in to leave comments.
Login now