mirror of
https://github.com/sprockets/sprockets.mixins.mediatype.git
synced 2024-11-22 03:00:25 +00:00
Add deprecation warnings for top-level items.
This commit is contained in:
parent
ce54332cab
commit
f9cda82f64
1 changed files with 21 additions and 0 deletions
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue