From 6275791bb8b9dfbed296328768cc548ef2607908 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 29 Oct 2009 14:31:27 -0400 Subject: [PATCH] Add DeprecatedFunctionWrapper. --- pytools/__init__.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pytools/__init__.py b/pytools/__init__.py index 62adeb0..c5d1093 100644 --- a/pytools/__init__.py +++ b/pytools/__init__.py @@ -1064,8 +1064,8 @@ def string_histogram(iterable, min_value=None, max_value=None, bin_count=20, wid format_bar(bin_value)) for bin_start, bin_value in zip(bin_starts, bins)) - - + + # command line interfaces ----------------------------------------------------- class CPyUserInterface(object): @@ -1144,6 +1144,21 @@ class CPyUserInterface(object): # obscure stuff -------------------------------------------------------------- +class DeprecatedFunctionWrapper: + def __init__(self, f): + self.f = f + + def __call__(self, *args, **kwargs): + from warnings import warn + warn("This function is deprecated. Use %s.%s instead." % ( + self.f.__module__, self.f.__name__), + DeprecationWarning, stacklevel=1) + + return self.f(*args, **kwargs) + + + + def enumerate_basic_directions(dimensions): coordinate_list = [[0], [1], [-1]] return reduce(cartesian_product_sum, [coordinate_list] * dimensions)[1:] -- GitLab