[docs]classGrabDeprecationWarning(UserWarning):""" Warning category used in Grab to generate warning messages. """
defwarn(msg,stacklevel=2):warnings.warn(msg,category=GrabDeprecationWarning,stacklevel=stacklevel)frame=sys._getframe()# pylint: disable=protected-accesslogging.debug('Deprecation Warning\n%s',''.join(traceback.format_stack(f=frame.f_back)))# from https://github.com/scrapy/scrapy/blob/master/scrapy/utils/decorator.pydefdeprecated(use_instead=None):"""This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used."""defwrapped(func):@wraps(func)defnew_func(*args,**kwargs):message="Call to deprecated function %s."%func.__name__ifuse_instead:message+=" Use %s instead."%use_insteadifnotDISABLE_WARNINGS:warn(message,stacklevel=3)returnfunc(*args,**kwargs)returnnew_funcreturnwrapped