Retrieve input by session. Parameters ---------- session : int Session number to retrieve. The current session is 0, and negative numbers count back from current session, so -1 is previous session. start : int First line to retriev
(
self,
session: int = 0,
start: int = 1,
stop: Optional[int] = None,
raw: bool = True,
output: bool = False,
)
| 932 | yield (0, i, line) |
| 933 | |
| 934 | def get_range( |
| 935 | self, |
| 936 | session: int = 0, |
| 937 | start: int = 1, |
| 938 | stop: Optional[int] = None, |
| 939 | raw: bool = True, |
| 940 | output: bool = False, |
| 941 | ) -> Iterable[tuple[int, int, InOrInOut]]: |
| 942 | """Retrieve input by session. |
| 943 | |
| 944 | Parameters |
| 945 | ---------- |
| 946 | session : int |
| 947 | Session number to retrieve. The current session is 0, and negative |
| 948 | numbers count back from current session, so -1 is previous session. |
| 949 | start : int |
| 950 | First line to retrieve. |
| 951 | stop : int |
| 952 | End of line range (excluded from output itself). If None, retrieve |
| 953 | to the end of the session. |
| 954 | raw : bool |
| 955 | If True, return untranslated input |
| 956 | output : bool |
| 957 | If True, attempt to include output. This will be 'real' Python |
| 958 | objects for the current session, or text reprs from previous |
| 959 | sessions if db_log_output was enabled at the time. Where no output |
| 960 | is found, None is used. |
| 961 | |
| 962 | Returns |
| 963 | ------- |
| 964 | entries |
| 965 | An iterator over the desired lines. Each line is a 3-tuple, either |
| 966 | (session, line, input) if output is False, or |
| 967 | (session, line, (input, output)) if output is True. |
| 968 | """ |
| 969 | if session <= 0: |
| 970 | session += self.session_number |
| 971 | if session == self.session_number: # Current session |
| 972 | return self._get_range_session(start, stop, raw, output) |
| 973 | return super(HistoryManager, self).get_range(session, start, stop, raw, output) |
| 974 | |
| 975 | ## ---------------------------- |
| 976 | ## Methods for storing history: |