mNantern/QTodoTxt — pull request #55 by monotasker (2014-03-15 15:28:06+00:00)
Title: Issue #47: Adding AND and OR syntax to text filter

I've added simple AND and OR operators to the SimpleTextFilter. The syntax is explained with examples in the docstring for the new SimpleTextFilter.isMatch(). I also added doctests to filters.doctest, all of which passed. Finally, I added some (basic and obvious) docstrings to other methods and classes in filters.py, simply because I enjoy writing documentation (which I think qualifies me as clinically insane). I also adjusted some of the line spacing and spacing around operators to satisfy the pep8 linter in my vim setup. If any of this isn't helpful or desirable I'm not offended to see it scrapped and just the filter logic merged.

I tried a few different approaches to the boolean processing, but settled on using the re module's re.sub to build a regex string which is then passed to re.search. The searches are still case insensitive (re.I) and unicode friendly (re.U). I used regex lookaheads to allow searching for the provided terms in any order.

This approach is comparatively fast, but it makes the NOT condition a bit tricky to implement. So the NOT syntax in my documentation isn't actually working. I've written docstrings to test that functionality, but commented them out in filters.doctest. I hope to get that NOT operator working, in which case I'll uncomment those doctests and send another pull request.

Cheers.