from ...lib.track import Track
from ...utils.utils import PluginException
+
def forge_filter(cfg):
tags = set(cfg.keys()) & Tags.supported_tags
cfg_filter = cfg.get('filter', None)
def _setup_tagsneeded(self):
config_tags = {k for k, v in self.plugin_conf.items() if v}
self.log.debug('%s plugin needs the followinng metadata: %s',
- self, config_tags & Tags.supported_tags)
+ self, config_tags & Tags.supported_tags)
tags = config_tags & Tags.supported_tags
self.player.needed_tags |= tags
def start(self):
if (0, 21, 0) > tuple(map(int, self.player.mpd_version.split('.'))):
self.log.warning('MPD protocol version: %s < 0.21.0',
- self.player.mpd_version)
- self.log.error('Need at least MPD 0.21 to use Tags plugin (filters required)')
+ self.player.mpd_version)
+ self.log.error(
+ 'Need at least MPD 0.21 to use Tags plugin (filters required)')
self.player.disconnect()
raise PluginException('MPD >= 0.21 required')
# Check filter is valid
"""
aka = push(bytes(dic.get('apikey') + '=', 'utf-8'))
aka = getencoder('rot-13')(str((aka), 'utf-8'))[0]
- dic.update({'apikey':aka})
+ dic.update({'apikey': aka})
+
def get_mpd_environ():
"""
passwd = mpd_host_env[1]
return (host, environ.get('MPD_PORT', None), passwd)
+
def normalize_path(path):
"""Get absolute path
"""
return normpath(join(getcwd(), path))
return path
+
def exception_log():
"""Log unknown exceptions"""
log = logging.getLogger(__name__)
class SigHup(Exception):
"""SIGHUP raises this Exception"""
- pass
+
# ArgParse Callbacks
class Obsolete(Action):
def __call__(self, parser, namespace, values, option_string=None):
raise ArgumentError(self, 'obsolete argument')
+
class FileAction(Action):
"""Generic class to inherit from for ArgParse action on file/dir
"""
"""
pass
+
class Wfile(FileAction):
# pylint: disable=R0903
"""Is file writable
if not access(self._file, W_OK):
self.parser.error('no write access to "{0}"'.format(self._file))
+
class Rfile(FileAction):
# pylint: disable=R0903
"""Is file readable
if not access(self._file, R_OK):
self.parser.error('no read access to "{0}"'.format(self._file))
+
class Wdir(FileAction):
# pylint: disable=R0903
"""Is directory writable
if not access(self._file, W_OK):
self.parser.error('no write access to "{0}"'.format(self._file))
+
class Throttle:
"""throttle decorator"""
def __init__(self, wait):
return result
return wrapper
+
class MPDSimaException(Exception):
- pass
+ """Generic MPD_sima Exception"""
+
# http client exceptions (for webservices)
class WSError(MPDSimaException):
pass
+
class WSNotFound(WSError):
pass
+
class WSTimeout(WSError):
pass
+
class WSHTTPError(WSError):
pass
+
class PluginException(MPDSimaException):
pass