From 25380fbbeddbc5f16347e80c2e278056113c5fbd Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 17 Nov 2013 15:45:57 +0100 Subject: [PATCH] mpd: Reformat query regexp --- mopidy/frontends/mpd/protocol/music_db.py | 31 ++++++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/mopidy/frontends/mpd/protocol/music_db.py b/mopidy/frontends/mpd/protocol/music_db.py index 85f80ad9..8e5f7593 100644 --- a/mopidy/frontends/mpd/protocol/music_db.py +++ b/mopidy/frontends/mpd/protocol/music_db.py @@ -9,10 +9,33 @@ from mopidy.frontends.mpd.exceptions import MpdArgError, MpdNotImplemented from mopidy.frontends.mpd.protocol import handle_request, stored_playlists -QUERY_RE = ( - r'(?P("?([Aa]lbum|[Aa]rtist|[Aa]lbumartist|[Cc]omment|' - r'[Cc]omposer|[Dd]ate|[Ff]ile|[Ff]ilename|[Gg]enre|[Pp]erformer|' - r'[Tt]itle|[Tt]rack|[Aa]ny)"?\ "[^"]*"\s?)+)$') +QUERY_RE = r""" + (?P + ( + "? # Optional quote around the field type + ( + [Aa]lbum + | [Aa]rtist + | [Aa]lbumartist + | [Cc]omment + | [Cc]omposer + | [Dd]ate + | [Ff]ile + | [Ff]ilename + | [Gg]enre + | [Pp]erformer + | [Tt]itle + | [Tt]rack + | [Aa]ny + ) + "? # End of optional quote around the field type + \ # A single space + "[^"]*" # Matching a quoted search string + \s? + )+ + ) + $ +""" def _get_field(field, search_results):