##// END OF EJS Templates
Update release_helper.sh from git switch...
Update release_helper.sh from git switch switch only works from branches not tags.

File last commit:

r27495:1a9d9554
r28493:f0d04dad Carreau-patch-1
Show More
ipython-get-history.py
40 lines | 1.1 KiB | text/x-python | PythonLexer
Thomas Kluyver
Add example script for extracting history from the database.
r4989 #!/usr/bin/env python
"""Extract a session from the IPython input history.
Usage:
ipython-get-history.py sessionnumber [outputfile]
If outputfile is not given, the relevant history is written to stdout. If
outputfile has a .py extension, the translated history (without IPython's
special syntax) will be extracted.
Example:
./ipython-get-history.py 57 record.ipy
This script is a simple demonstration of HistoryAccessor. It should be possible
to build much more flexible and powerful tools to browse and pull from the
history database.
"""
import sys
rushabh-v
use pathlib in ipython-get-history.py
r26145 from pathlib import Path
Thomas Kluyver
Add example script for extracting history from the database.
r4989
from IPython.core.history import HistoryAccessor
session_number = int(sys.argv[1])
if len(sys.argv) > 2:
rushabh-v
use pathlib in ipython-get-history.py
r26145 filepath = Path(sys.argv[2])
gousaiyang
Format code
r27495 dest = open(filepath, "w", encoding="utf-8")
rushabh-v
run darker
r26147 raw = not filepath.name.endswith(".py")
Thomas Kluyver
Add example script for extracting history from the database.
r4989 else:
dest = sys.stdout
raw = True
Mickaël Schoentgen
Fix ResourceWarning: unclosed file...
r24897 with dest:
dest.write("# coding: utf-8\n")
Thomas Kluyver
Add example script for extracting history from the database.
r4989
Mickaël Schoentgen
Fix ResourceWarning: unclosed file...
r24897 # Profiles other than 'default' can be specified here with a profile= argument:
hist = HistoryAccessor()
for session, lineno, cell in hist.get_range(session=session_number, raw=raw):
dest.write(cell + '\n')