1
"""Module with little helper functions and classes:
3
deprecated - decorator to emit a warning if a depreacted function is used
5
#Copyright (C) 2008-2009 Sebastian Heinlein <sevel@glatzor.de>
7
#Licensed under the GNU General Public License Version 2
9
#This program is free software; you can redistribute it and/or modify
10
#it under the terms of the GNU General Public License as published by
11
#the Free Software Foundation; either version 2 of the License, or
12
#(at your option) any later version.
14
#This program is distributed in the hope that it will be useful,
15
#but WITHOUT ANY WARRANTY; without even the implied warranty of
16
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
#GNU General Public License for more details.
19
#You should have received a copy of the GNU General Public License
20
#along with this program; if not, write to the Free Software
21
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
__author__ = "Sebastian Heinlein <devel@glatzor.de>"
29
"""This is a decorator which can be used to mark functions
30
as deprecated. It will result in a warning being emitted
31
when the function is used.
33
Taken from http://wiki.python.org/moin/PythonDecoratorLibrary
34
#GeneratingDeprecationWarnings
36
@functools.wraps(func)
37
def new_func(*args, **kwargs):
38
warnings.warn_explicit(
39
"Call to deprecated function %(funcname)s." % {
40
'funcname': func.__name__,
42
category=DeprecationWarning,
43
filename=func.func_code.co_filename,
44
lineno=func.func_code.co_firstlineno + 1
46
return func(*args, **kwargs)