/usr/share/pyshared/cogent/util/warning.py is in python-cogent 1.5.3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #!/usr/bin/env python
from warnings import catch_warnings, simplefilter, warn as _warn
__author__ = "Gavin Huttley"
__copyright__ = "Copyright 2007-2012, The Cogent Project"
__credits__ = ["Gavin Huttley", "Jai Ram Rideout"]
__license__ = "GPL"
__version__ = "1.5.3"
__maintainer__ = "Gavin Huttley"
__email__ = "gavin.huttley@anu.edu.au"
__status__ = "Production"
def deprecated(_type, old, new, version, stack_level=2):
"""a convenience function for deprecating classes, functions, arguments.
Arguments:
- _type should be one of class, method, function, argument
- old, new: the old and new names
- version: the version by which support for the old name will be
discontinued
- stack_level: as per warnings.warn"""
msg = "use %s %s instead of %s, support discontinued in version %s" % \
(_type, new, old, version)
# DeprecationWarnings are ignored by default in python 2.7, so temporarily
# force them to be handled.
with catch_warnings():
simplefilter("always")
_warn(msg, DeprecationWarning, stack_level)
def discontinued(_type, name, version, stack_level=2):
"""convenience func to warn about discontinued attributes
Arguments:
- _type should be one of class, method, function, argument
- name: the attributes name
- version: the version by which support for the old name will be
discontinued
- stack_level: as per warnings.warn"""
msg = "%s %s is discontinued, support will be stopped in version %s" %\
(_type, name, version)
with catch_warnings():
simplefilter("always")
_warn(msg, DeprecationWarning, stack_level)
|