=== modified file 'xl/trackdb.py' --- xl/trackdb.py 2009-09-08 19:35:49 +0000 +++ xl/trackdb.py 2009-10-23 18:37:44 +0000 @@ -468,6 +468,7 @@ search = search.replace(" OR ", " | ") search = search.replace(" NOT ", " ! ") + tokens = [] newsearch = "" in_quotes = False n = 0 @@ -482,55 +483,17 @@ elif in_quotes and c != "\"": newsearch += c elif c == "\"": - in_quotes = in_quotes == False # toggle - newsearch += c + in_quotes = not in_quotes # toggle + #newsearch += c elif c in ["|", "!", "(", ")"]: - newsearch += " " + c + " " + newsearch += c elif c == " ": - try: - if search[n+1] != " ": - if search[n+1] not in ["=", ">", "<"]: - newsearch += " " - except IndexError: - pass + tokens.append(newsearch) + newsearch = "" else: newsearch += c n += 1 - - # split the search into tokens to be parsed - search = " " + newsearch.lower() + " " - tokens = search.split(" ") - tokens = [t for t in tokens if t != ""] - - # handle "" grouping - etokens = [] - counter = 0 - while counter < len(tokens): - if '"' in tokens[counter]: - tk = tokens[counter] - while tk.count('"') - tk.count('\\"') < 2: - try: - tk += " " + tokens[counter+1] - counter += 1 - except IndexError: # someone didnt match their "s - break - first = tk.index('"', 0) - last = first - while True: - try: - last = tk.index('"', last+1) - except ValueError: - break - tk = tk[:first] + tk[first+1:last] + tk[last+1:] - etokens.append(tk) - counter += 1 - else: - if tokens[counter].strip() is not "": - etokens.append(tokens[counter]) - counter += 1 - tokens = etokens - # reduce tokens to a search tree and optimize it tokens = self.__red(tokens) tokens = self.__optimize_tokens(tokens)