diff --git a/mopidy/mpd/protocol/channels.py b/mopidy/mpd/protocol/channels.py index e8efd2a0..4ae00622 100644 --- a/mopidy/mpd/protocol/channels.py +++ b/mopidy/mpd/protocol/channels.py @@ -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[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[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[A-Za-z0-9:._-]+)"\ "(?P[^"]*)"$') +@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 diff --git a/mopidy/mpd/protocol/empty.py b/mopidy/mpd/protocol/empty.py deleted file mode 100644 index 64cfc1fb..00000000 --- a/mopidy/mpd/protocol/empty.py +++ /dev/null @@ -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() diff --git a/mopidy/mpd/protocol/stickers.py b/mopidy/mpd/protocol/stickers.py index 17798523..53ce0caa 100644 --- a/mopidy/mpd/protocol/stickers.py +++ b/mopidy/mpd/protocol/stickers.py @@ -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[^"]+)"\ ' - r'"(?P[^"]+)"(\ "(?P[^"]+)")*$') -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[^"]+)"\ "(?P[^"]+)"\ ' - r'"(?P[^"]+)"$') -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[^"]+)"\ "(?P[^"]+)"\ ' - r'"(?P[^"]+)"$') -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[^"]+)"\ "(?P[^"]+)"$') -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[^"]+)"\ "(?P[^"]+)"\ ' - r'"(?P[^"]+)"\ "(?P[^"]+)"$') -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