=== modified file 'xl/trackdb.py' --- xl/trackdb.py 2009-09-08 18:29:32 +0000 +++ xl/trackdb.py 2009-09-08 23:12:18 +0000 @@ -458,6 +458,31 @@ self._dirty = True +def dirty_space_split(s): + l = [] + current = "" + in_quotes = False + ignore = False + for c in s: + if ignore: + ignore = False + current += c + elif c == "\\": + ignore = True + elif in_quotes and not c == '"': + current += c + elif c == '"': + in_quotes = not in_quotes + current += c + elif c == ' ': + l.append(current) + current = "" + else: + current += c + if current != "": + l.append(current) + return l + class TrackSearcher(object): """ Search a TrackDB for matching tracks @@ -477,6 +502,7 @@ while n < len(search): c = search[n] if c == "\\": + newsearch += c n += 1 try: newsearch += search[n] @@ -503,7 +529,7 @@ # split the search into tokens to be parsed search = " " + newsearch.lower() + " " - tokens = search.split(" ") + tokens = dirty_space_split(search) tokens = [t for t in tokens if t != ""] # handle "" grouping