Store source and raw input in history and create input cache variables ``_i*``. Parameters ---------- line_num : int The prompt number of this input. source : str Python input. source_raw : str, optional If given, this
(self, line_num, source, source_raw=None)
| 689 | ## Methods for storing history: |
| 690 | ## ---------------------------- |
| 691 | def store_inputs(self, line_num, source, source_raw=None): |
| 692 | """Store source and raw input in history and create input cache |
| 693 | variables ``_i*``. |
| 694 | |
| 695 | Parameters |
| 696 | ---------- |
| 697 | line_num : int |
| 698 | The prompt number of this input. |
| 699 | |
| 700 | source : str |
| 701 | Python input. |
| 702 | |
| 703 | source_raw : str, optional |
| 704 | If given, this is the raw input without any IPython transformations |
| 705 | applied to it. If not given, ``source`` is used. |
| 706 | """ |
| 707 | if source_raw is None: |
| 708 | source_raw = source |
| 709 | source = source.rstrip('\n') |
| 710 | source_raw = source_raw.rstrip('\n') |
| 711 | |
| 712 | # do not store exit/quit commands |
| 713 | if self._exit_re.match(source_raw.strip()): |
| 714 | return |
| 715 | |
| 716 | self.input_hist_parsed.append(source) |
| 717 | self.input_hist_raw.append(source_raw) |
| 718 | |
| 719 | with self.db_input_cache_lock: |
| 720 | self.db_input_cache.append((line_num, source, source_raw)) |
| 721 | # Trigger to flush cache and write to DB. |
| 722 | if len(self.db_input_cache) >= self.db_cache_size: |
| 723 | self.save_flag.set() |
| 724 | |
| 725 | # update the auto _i variables |
| 726 | self._iii = self._ii |
| 727 | self._ii = self._i |
| 728 | self._i = self._i00 |
| 729 | self._i00 = source_raw |
| 730 | |
| 731 | # hackish access to user namespace to create _i1,_i2... dynamically |
| 732 | new_i = '_i%s' % line_num |
| 733 | to_main = {'_i': self._i, |
| 734 | '_ii': self._ii, |
| 735 | '_iii': self._iii, |
| 736 | new_i : self._i00 } |
| 737 | |
| 738 | if self.shell is not None: |
| 739 | self.shell.push(to_main, interactive=False) |
| 740 | |
| 741 | def store_output(self, line_num): |
| 742 | """If database output logging is enabled, this saves all the |