mopidy/mopidy/utils/deprecation.py
Thomas Adamcik e4ba4b3e5f mpd: Support blacklisting MPD commands in the server.
Default blacklist set to listall and listallinfo.

This change has been done to avoid clients being able to call "bad" MPD
commands which are often misused to try and keep a client db. Note that
this change will break some MPD clients, but the blacklist can be controlled
via config to allow opting out for now.
2015-02-18 00:13:24 +01:00

36 lines
973 B
Python

from __future__ import unicode_literals
import inspect
import warnings
def _is_pykka_proxy_creation():
return False
stack = inspect.stack()
try:
calling_frame = stack[3]
except IndexError:
return False
else:
filename = calling_frame[1]
funcname = calling_frame[3]
return 'pykka' in filename and funcname == '_get_attributes'
def deprecated_property(
getter=None, setter=None, message='Property is deprecated'):
def deprecated_getter(*args):
if not _is_pykka_proxy_creation():
warnings.warn(message, DeprecationWarning, stacklevel=2)
return getter(*args)
def deprecated_setter(*args):
if not _is_pykka_proxy_creation():
warnings.warn(message, DeprecationWarning, stacklevel=2)
return setter(*args)
new_getter = getter and deprecated_getter
new_setter = setter and deprecated_setter
return property(new_getter, new_setter)