Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/treelib/misc.py: 62%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/bin/env python
2# Copyright (C) 2011
3# Brett Alistair Kromkamp - brettkromkamp@gmail.com
4# Copyright (C) 2012-2025
5# Xiaming Chen - chenxm35@gmail.com
6# and other contributors.
7# All rights reserved.
8import functools
9from warnings import simplefilter, warn
12def deprecated(alias):
13 def real_deco(func):
14 """This is a decorator which can be used to mark functions
15 as deprecated. It will result in a warning being emmitted
16 when the function is used.
17 Derived from answer by Leando: https://stackoverflow.com/a/30253848
18 """
20 @functools.wraps(func)
21 def wrapper(*args, **kwargs):
22 simplefilter("always", DeprecationWarning) # turn off filter
23 warn(
24 'Call to deprecated function "{}"; use "{}" instead.'.format(func.__name__, alias),
25 category=DeprecationWarning,
26 stacklevel=2,
27 )
28 simplefilter("default", DeprecationWarning) # reset filter
29 return func(*args, **kwargs)
31 return wrapper
33 return real_deco