1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 __authors__ = [ "Jérôme Kieffer" ]
29 __contact__ = "kieffer@esrf.fr"
30 __license__ = "LGPLv3+"
31 __copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
32 __date__ = "20120213"
33
34 import os, traceback, time
35 from EDVerbose import EDVerbose
36
38 def wrapper(*arg, **kw):
39 """
40 decorator that deprecates the use of a function
41 """
42 EDVerbose.WARNING("%s is Deprecated !!! %s" % (func.func_name, os.linesep.join([""] + traceback.format_stack()[:-1])))
43 return func(*arg, **kw)
44 return wrapper
45
46
48 def wrapper(*arg, **kw):
49 '''This is the docstring from timeit:
50 a decorator that prints the execution time'''
51 t1 = time.time()
52 res = func(*arg, **kw)
53 EDVerbose.WARNING("%s took %.3fs" % (func.func_name, time.time() - t1))
54 return res
55 return wrapper
56