Commit bd0315c8 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Add negation operator.

parent ca43307d
......@@ -333,3 +333,12 @@ class OrdinalTagFilterTest(unittest.TestCase):
self.assertEquals(len(result), 2)
self.assertEquals(str(result[0]), "Foo due:%s" % self.today)
self.assertEquals(str(result[1]), "Bar due:%s" % self.tomorrow)
def test_filter5(self):
otf = Filter.OrdinalTagFilter('due:!today')
result = otf.filter(self.todos)
self.assertEquals(len(result), 1)
self.assertEquals(str(result[0]), "Bar due:%s" % self.tomorrow)
......@@ -148,7 +148,7 @@ class LimitFilter(Filter):
def filter(self, p_todos):
return p_todos[:self.limit] if self.limit >= 0 else p_todos
ORDINAL_TAG_MATCH = r"(?P<key>[^:]*):(?P<operator><=?|=|>=?)?(?P<value>\S*)"
ORDINAL_TAG_MATCH = r"(?P<key>[^:]*):(?P<operator><=?|=|>=?|!)?(?P<value>\S*)"
class OrdinalTagFilter(Filter):
def __init__(self, p_expression):
......@@ -188,5 +188,7 @@ class OrdinalTagFilter(Filter):
return operand1 >= operand2
elif self.operator == '>':
return operand1 > operand2
elif self.operator == '!':
return operand1 != operand2
return False
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment