Add deprecation warnings for top-level items.

This commit is contained in:
Dave Shawley 2016-01-10 10:44:53 -05:00
parent ce54332cab
commit f9cda82f64

View file

@ -2,6 +2,9 @@
sprockets.mixins.media_type
"""
import functools
import warnings
try:
from .content import (ContentMixin, ContentSettings,
add_binary_content_type, add_text_content_type,
@ -17,6 +20,24 @@ except ImportError as error: # pragma no cover
add_text_content_type = _error_closure
set_default_content_type = _error_closure
def _mark_deprecated(func):
msg = '{0}.{1} is deprecated, use {0}.content.{1} instead'.format(
'sprockets.mixins.mediatype', func.__name__)
@functools.wraps(func)
def wrapper(*args, **kwargs):
warnings.warn(msg, category=DeprecationWarning)
return func(*args, **kwargs)
return wrapper
add_binary_content_type = _mark_deprecated(add_binary_content_type)
add_text_content_type = _mark_deprecated(add_text_content_type)
set_default_content_type = _mark_deprecated(set_default_content_type)
ContentMixin = _mark_deprecated(ContentMixin)
ContentSettings = _mark_deprecated(ContentSettings)
version_info = (1, 0, 4)
__version__ = '.'.join(str(v) for v in version_info)
__all__ = ('ContentMixin', 'ContentSettings', 'add_binary_content_type',