MPD encoding is declared as UTF-8 in the standard, so it should be a constant instead of a setting

This commit is contained in:
Stein Magnus Jodal 2010-02-22 23:48:43 +01:00
parent 3cff0edc9e
commit cade4b67f8
2 changed files with 6 additions and 7 deletions

View File

@ -7,6 +7,9 @@ from mopidy.mpd.handler import MpdHandler
logger = logging.getLogger(u'mpd.session')
#: All data between the client and the server is encoded in UTF-8.
ENCODING = 'utf-8'
def indent(string, places=4, linebreak=config.MPD_LINE_TERMINATOR):
lines = string.split(linebreak)
if len(lines) == 1:
@ -23,8 +26,7 @@ class MpdSession(asynchat.async_chat):
self.server = server
self.client_address = client_address
self.input_buffer = []
self.set_terminator(config.MPD_LINE_TERMINATOR.encode(
config.MPD_LINE_ENCODING))
self.set_terminator(config.MPD_LINE_TERMINATOR.encode(ENCODING))
self.handler = handler_class(session=self, backend=backend)
self.send_response(u'OK MPD %s' % get_mpd_protocol_version())
@ -41,7 +43,7 @@ class MpdSession(asynchat.async_chat):
def found_terminator(self):
data = ''.join(self.input_buffer).strip()
self.input_buffer = []
input = data.decode(config.MPD_LINE_ENCODING)
input = data.decode(ENCODING)
logger.debug(u'Input: %s', indent(input))
self.handle_request(input)
@ -60,7 +62,7 @@ class MpdSession(asynchat.async_chat):
def send_response(self, output):
logger.debug(u'Output: %s', indent(output))
output = u'%s%s' % (output, config.MPD_LINE_TERMINATOR)
data = output.encode(config.MPD_LINE_ENCODING)
data = output.encode(ENCODING)
self.push(data)
def stats_uptime(self):

View File

@ -31,9 +31,6 @@ BACKENDS = (
#: the format.
CONSOLE_LOG_FORMAT = u'%(levelname)-8s %(asctime)s [%(threadName)s] %(name)s\n %(message)s'
#: Encoding used in MPD protocol. *Default:* ``utf-8``
MPD_LINE_ENCODING = u'utf-8'
#: Line terminator character used in MPD protocol. *Default:* ``\n``
MPD_LINE_TERMINATOR = u'\n'