##// END OF EJS Templates
add genutils.wrap_deprecated
vivainio -
Show More
@@ -5,7 +5,7 b' General purpose utilities.'
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
5 This is a grab-bag of stuff I find useful in most programs I write. Some of
6 these things are also convenient when working at the command line.
6 these things are also convenient when working at the command line.
7
7
8 $Id: genutils.py 1845 2006-10-27 20:35:47Z fptest $"""
8 $Id: genutils.py 1930 2006-11-26 17:22:13Z vivainio $"""
9
9
10 #*****************************************************************************
10 #*****************************************************************************
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
11 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
@@ -30,6 +30,7 b' import sys'
30 import tempfile
30 import tempfile
31 import time
31 import time
32 import types
32 import types
33 import warnings
33
34
34 # Other IPython utilities
35 # Other IPython utilities
35 from IPython.Itpl import Itpl,itpl,printpl
36 from IPython.Itpl import Itpl,itpl,printpl
@@ -1697,6 +1698,7 b' def import_fail_info(mod_name,fns=None):'
1697 #----------------------------------------------------------------------------
1698 #----------------------------------------------------------------------------
1698 # Proposed popitem() extension, written as a method
1699 # Proposed popitem() extension, written as a method
1699
1700
1701
1700 class NotGiven: pass
1702 class NotGiven: pass
1701
1703
1702 def popkey(dct,key,default=NotGiven):
1704 def popkey(dct,key,default=NotGiven):
@@ -1715,5 +1717,15 b' def popkey(dct,key,default=NotGiven):'
1715 else:
1717 else:
1716 del dct[key]
1718 del dct[key]
1717 return val
1719 return val
1720
1721 def wrap_deprecated(func, suggest = '<nothing>'):
1722 def newFunc(*args, **kwargs):
1723 warnings.warn("Call to deprecated function %s, use %s instead" %
1724 ( func.__name__, suggest),
1725 category=DeprecationWarning,
1726 stacklevel = 2)
1727 return func(*args, **kwargs)
1728 return newFunc
1729
1718 #*************************** end of file <genutils.py> **********************
1730 #*************************** end of file <genutils.py> **********************
1719
1731
General Comments 0
You need to be logged in to leave comments. Login now