[Yt-svn] yt-commit r647 - trunk/yt
mturk at wrangler.dreamhost.com
mturk at wrangler.dreamhost.com
Sat Jul 5 10:46:17 PDT 2008
Author: mturk
Date: Sat Jul 5 10:46:16 2008
New Revision: 647
URL: http://yt.spacepope.org/changeset/647
Log:
Added a simple @print_tb decorator.
Modified:
trunk/yt/funcs.py
Modified: trunk/yt/funcs.py
==============================================================================
--- trunk/yt/funcs.py (original)
+++ trunk/yt/funcs.py Sat Jul 5 10:46:16 2008
@@ -26,6 +26,14 @@
import time, types
import progressbar as pb
+def blank_wrapper(f):
+ return f
+
+try:
+ from functools import wraps
+except ImportError:
+ wraps = blank_wrapper
+
def iterable(obj):
"""
Grabbed from Python Cookbook / matploblib.cbook
@@ -46,6 +54,7 @@
Decorator for seeing how long a given function takes, depending on whether
or not the global 'yt.timefunctions' config parameter is set.
"""
+ @wraps(func)
def wrapper(*arg, **kw):
t1 = time.time()
res = func(*arg, **kw)
@@ -119,6 +128,13 @@
self.__setitem__(key, self.__func())
return dict.__getitem__(self, key)
+import traceback
+def print_tb(func):
+ def run_func(*args, **kwargs):
+ traceback.print_stack()
+ func(*args, **kwargs)
+ return run_func
+
try:
from collections import defaultdict
except ImportError:
More information about the yt-svn
mailing list