##// END OF EJS Templates
Merge pull request #1363 from minrk/qtstyle...
Merge pull request #1363 from minrk/qtstyle Fix some minor color/style config issues in the qtconsole The tabbed code changed a few things about loading styles and stylesheets in the qtconsole, which this resolves, among a couple other small color-related issues: * tabs other than the first get colors * IPythonWidget.style_sheet configurable is not clobbered by defaults * style_sheet configurable would cause a crash, because _style_sheet_changed could be called before _control existed * fix str->unicode token preventing stylesheets without syntax highlighting from working * fix typo in the function used to detect whether a bgcolor is dark or light

File last commit:

r4989:a355a9f7
r6095:2b3bc441 merge
Show More
ipython-get-history.py
38 lines | 1.1 KiB | text/x-python | PythonLexer
/ docs / examples / core / ipython-get-history.py
#!/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
import codecs
from IPython.core.history import HistoryAccessor
session_number = int(sys.argv[1])
if len(sys.argv) > 2:
dest = open(sys.argv[2], "w")
raw = not sys.argv[2].endswith('.py')
else:
dest = sys.stdout
raw = True
dest.write("# coding: utf-8\n")
# 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):
# To use this in Python 3, remove the .encode() here:
dest.write(cell.encode('utf-8') + '\n')