mpd: Convert channels and stickers and delete empty.

This commit is contained in:
Thomas Adamcik 2014-01-23 21:41:06 +01:00
parent fddb299ed9
commit 1dc35c2bf7
3 changed files with 35 additions and 81 deletions

View File

@ -1,10 +1,9 @@
from __future__ import unicode_literals
from mopidy.mpd.protocol import handle_request
from mopidy.mpd.exceptions import MpdNotImplemented
from mopidy.mpd import exceptions, protocol
@handle_request(r'subscribe\ "(?P<channel>[A-Za-z0-9:._-]+)"$')
@protocol.commands.add('subscribe')
def subscribe(context, channel):
"""
*musicpd.org, client to client section:*
@ -15,10 +14,11 @@ def subscribe(context, channel):
already. The name may consist of alphanumeric ASCII characters plus
underscore, dash, dot and colon.
"""
raise MpdNotImplemented # TODO
# TODO: match channel against [A-Za-z0-9:._-]+
raise exceptions.MpdNotImplemented # TODO
@handle_request(r'unsubscribe\ "(?P<channel>[A-Za-z0-9:._-]+)"$')
@protocol.commands.add('unsubscribe')
def unsubscribe(context, channel):
"""
*musicpd.org, client to client section:*
@ -27,10 +27,11 @@ def unsubscribe(context, channel):
Unsubscribe from a channel.
"""
raise MpdNotImplemented # TODO
# TODO: match channel against [A-Za-z0-9:._-]+
raise exceptions.MpdNotImplemented # TODO
@handle_request(r'channels$')
@protocol.commands.add('channels')
def channels(context):
"""
*musicpd.org, client to client section:*
@ -40,10 +41,10 @@ def channels(context):
Obtain a list of all channels. The response is a list of "channel:"
lines.
"""
raise MpdNotImplemented # TODO
raise exceptions.MpdNotImplemented # TODO
@handle_request(r'readmessages$')
@protocol.commands.add('readmessages')
def readmessages(context):
"""
*musicpd.org, client to client section:*
@ -53,11 +54,10 @@ def readmessages(context):
Reads messages for this client. The response is a list of "channel:"
and "message:" lines.
"""
raise MpdNotImplemented # TODO
raise exceptions.MpdNotImplemented # TODO
@handle_request(
r'sendmessage\ "(?P<channel>[A-Za-z0-9:._-]+)"\ "(?P<text>[^"]*)"$')
@protocol.commands.add('sendmessage')
def sendmessage(context, channel, text):
"""
*musicpd.org, client to client section:*
@ -66,4 +66,5 @@ def sendmessage(context, channel, text):
Send a message to the specified channel.
"""
raise MpdNotImplemented # TODO
# TODO: match channel against [A-Za-z0-9:._-]+
raise exceptions.MpdNotImplemented # TODO

View File

@ -1,10 +0,0 @@
from __future__ import unicode_literals
from mopidy.mpd.protocol import handle_request
from mopidy.mpd.exceptions import MpdNoCommand
@handle_request(r'[\ ]*$')
def empty(context):
"""The original MPD server returns an error on an empty request."""
raise MpdNoCommand()

View File

@ -1,76 +1,39 @@
from __future__ import unicode_literals
from mopidy.mpd.protocol import handle_request
from mopidy.mpd.exceptions import MpdNotImplemented
from mopidy.mpd import exceptions, protocol
@handle_request(
r'sticker\ delete\ "(?P<field>[^"]+)"\ '
r'"(?P<uri>[^"]+)"(\ "(?P<name>[^"]+)")*$')
def sticker__delete(context, field, uri, name=None):
"""
*musicpd.org, sticker section:*
``sticker delete {TYPE} {URI} [NAME]``
Deletes a sticker value from the specified object. If you do not
specify a sticker name, all sticker values are deleted.
"""
raise MpdNotImplemented # TODO
@handle_request(
r'sticker\ find\ "(?P<field>[^"]+)"\ "(?P<uri>[^"]+)"\ '
r'"(?P<name>[^"]+)"$')
def sticker__find(context, field, uri, name):
"""
*musicpd.org, sticker section:*
``sticker find {TYPE} {URI} {NAME}``
Searches the sticker database for stickers with the specified name,
below the specified directory (``URI``). For each matching song, it
prints the ``URI`` and that one sticker's value.
"""
raise MpdNotImplemented # TODO
@handle_request(
r'sticker\ get\ "(?P<field>[^"]+)"\ "(?P<uri>[^"]+)"\ '
r'"(?P<name>[^"]+)"$')
def sticker__get(context, field, uri, name):
"""
*musicpd.org, sticker section:*
``sticker get {TYPE} {URI} {NAME}``
Reads a sticker value for the specified object.
"""
raise MpdNotImplemented # TODO
@handle_request(r'sticker\ list\ "(?P<field>[^"]+)"\ "(?P<uri>[^"]+)"$')
def sticker__list(context, field, uri):
@protocol.commands.add('sticker')
def sticker(context, action, field, uri, name=None, value=None):
"""
*musicpd.org, sticker section:*
``sticker list {TYPE} {URI}``
Lists the stickers for the specified object.
"""
raise MpdNotImplemented # TODO
``sticker find {TYPE} {URI} {NAME}``
Searches the sticker database for stickers with the specified name,
below the specified directory (``URI``). For each matching song, it
prints the ``URI`` and that one sticker's value.
``sticker get {TYPE} {URI} {NAME}``
Reads a sticker value for the specified object.
@handle_request(
r'sticker\ set\ "(?P<field>[^"]+)"\ "(?P<uri>[^"]+)"\ '
r'"(?P<name>[^"]+)"\ "(?P<value>[^"]+)"$')
def sticker__set(context, field, uri, name, value):
"""
*musicpd.org, sticker section:*
``sticker set {TYPE} {URI} {NAME} {VALUE}``
Adds a sticker value to the specified object. If a sticker item
with that name already exists, it is replaced.
``sticker delete {TYPE} {URI} [NAME]``
Deletes a sticker value from the specified object. If you do not
specify a sticker name, all sticker values are deleted.
"""
raise MpdNotImplemented # TODO
# TODO: check that action in ('list', 'find', 'get', 'set', 'delete')
# TODO: check name/value matches with action
raise exceptions.MpdNotImplemented # TODO