Fix pylint warnings in MPD frontend

This commit is contained in:
Stein Magnus Jodal 2011-06-04 18:24:06 +02:00
parent 68a671414c
commit e6294ec869
4 changed files with 12 additions and 7 deletions

View File

@ -7,7 +7,7 @@ from pykka.registry import ActorRegistry
from mopidy import settings
from mopidy.backends.base import Backend
from mopidy.frontends.mpd.exceptions import (MpdAckError, MpdArgError,
MpdPermissionError, MpdPasswordError, MpdSystemError, MpdUnknownCommand)
MpdPermissionError, MpdSystemError, MpdUnknownCommand)
from mopidy.frontends.mpd.protocol import mpd_commands, request_handlers
# Do not remove the following import. The protocol modules must be imported to
# get them registered as request handlers.
@ -74,7 +74,8 @@ class MpdDispatcher(object):
return self._call_next_filter(request, response, filter_chain)
else:
command = request.split(' ')[0]
if command in ('close', 'commands', 'notcommands', 'password', 'ping'):
if command in (
'close', 'commands', 'notcommands', 'password', 'ping'):
return self._call_next_filter(request, response, filter_chain)
else:
raise MpdPermissionError(command=command)
@ -142,7 +143,7 @@ class MpdDispatcher(object):
def _format_response(self, response):
formatted_response = []
for element in self._listify_result(response):
formatted_response.extend(self._format_lines(element))
formatted_response.extend(self._format_lines(element))
return formatted_response
def _listify_result(self, result):

View File

@ -36,7 +36,8 @@ def command_list_end(context):
response = context.dispatcher.handle_request(
command, current_command_list_index=index)
command_list_response.extend(response)
if command_list_response and command_list_response[-1].startswith(u'ACK'):
if (command_list_response and
command_list_response[-1].startswith(u'ACK')):
return command_list_response
if command_list_ok:
command_list_response.append(u'list_OK')

View File

@ -52,7 +52,8 @@ class MpdServer(asyncore.dispatcher):
self._format_hostname(settings.MPD_SERVER_HOSTNAME),
settings.MPD_SERVER_PORT)
except IOError, e:
logger.error(u'MPD server startup failed: %s' % str(e).decode('utf-8'))
logger.error(u'MPD server startup failed: %s' %
str(e).decode('utf-8'))
sys.exit(1)
def handle_accept(self):

View File

@ -1,7 +1,6 @@
import asynchat
import logging
from mopidy import settings
from mopidy.frontends.mpd.dispatcher import MpdDispatcher
from mopidy.frontends.mpd.protocol import ENCODING, LINE_TERMINATOR, VERSION
from mopidy.utils.log import indent
@ -46,7 +45,10 @@ class MpdSession(asynchat.async_chat):
return self.dispatcher.handle_request(request)
def send_response(self, response):
"""Format a response from the MPD command handlers and send it to the client."""
"""
Format a response from the MPD command handlers and send it to the
client.
"""
if response is not None:
response = LINE_TERMINATOR.join(response)
logger.debug(u'Response to [%s]:%s: %s', self.client_address,