decorators.py 701 B

1234567891011121314151617181920
  1. # -*- coding: utf-8 -*-
  2. # Copyright (C) 2015-2016 Peter Magnusson <peter@birchroad.net>
  3. """Decorators used in the module"""
  4. import warnings
  5. def deprecated(func):
  6. """This is a decorator which can be used to mark functions
  7. as deprecated. It will result in a warning being emmitted
  8. when the function is used."""
  9. def new_func(*args, **kwargs):
  10. """whatever"""
  11. warnings.warn("Call to deprecated function %s." % func.__name__,
  12. category=DeprecationWarning)
  13. return func(*args, **kwargs)
  14. new_func.__name__ = func.__name__
  15. new_func.__doc__ = func.__doc__
  16. new_func.__dict__.update(func.__dict__)
  17. return new_func