[Yt-svn] yt-commit r1230 - trunk/yt
mturk at wrangler.dreamhost.com
mturk at wrangler.dreamhost.com
Mon Mar 23 21:42:00 PDT 2009
Author: mturk
Date: Mon Mar 23 21:41:59 2009
New Revision: 1230
URL: http://yt.spacepope.org/changeset/1230
Log:
Added new function, insert_ipython. Anywhere you insert this, you will get
dumped into an IPython shell populated with the locals and globals.
Modified:
trunk/yt/funcs.py
Modified: trunk/yt/funcs.py
==============================================================================
--- trunk/yt/funcs.py (original)
+++ trunk/yt/funcs.py Mon Mar 23 21:41:59 2009
@@ -23,7 +23,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
-import time, types, signal, traceback, sys, pdb
+import time, types, signal, inspect, traceback, sys, pdb
import progressbar as pb
from math import floor, ceil
@@ -100,6 +100,29 @@
pdb.runcall(func, *args, **kw)
return wrapper
+__header = """
+== Welcome to the embedded IPython Shell ==
+
+ You are currently inside the function:
+ %(fname)s
+
+ Defined in:
+ %(filename)s:%(lineno)s
+"""
+
+def insert_ipython():
+ from IPython.Shell import IPShellEmbed
+ stack = inspect.stack()
+ frame = inspect.stack()[1]
+ loc = frame[0].f_locals.copy()
+ glo = frame[0].f_globals
+ dd = dict(fname = frame[3], filename = frame[1],
+ lineno = frame[2])
+ ipshell = IPShellEmbed()
+ ipshell(header = __header % dd,
+ local_ns = loc, global_ns = glo)
+ del ipshell
+
class DummyProgressBar:
def __init__(self, *args, **kwargs):
return
More information about the yt-svn
mailing list