Commit 674947f4 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Properly deal with integers passed as expression.

Conflicts:
	test/FilterTest.py
parent 8e32cf75
...@@ -185,6 +185,13 @@ class FilterTest(unittest.TestCase): ...@@ -185,6 +185,13 @@ class FilterTest(unittest.TestCase):
todolist_to_string(reference)) todolist_to_string(reference))
def test_filter19(self): def test_filter19(self):
todos = load_file('data/FilterTest1.txt')
grep = Filter.GrepFilter(1)
filtered_todos = grep.filter(todos)
self.assertEquals(filtered_todos, [])
def test_filter20(self):
todos = load_file('data/FilterTest3.txt') todos = load_file('data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('due:<2014-11-10') otf = Filter.OrdinalTagFilter('due:<2014-11-10')
...@@ -194,7 +201,7 @@ class FilterTest(unittest.TestCase): ...@@ -194,7 +201,7 @@ class FilterTest(unittest.TestCase):
self.assertEquals(todolist_to_string(filtered_todos), \ self.assertEquals(todolist_to_string(filtered_todos), \
todolist_to_string(reference)) todolist_to_string(reference))
def test_filter20(self): def test_filter21(self):
todos = load_file('data/FilterTest3.txt') todos = load_file('data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('due:=2014-11-10') otf = Filter.OrdinalTagFilter('due:=2014-11-10')
...@@ -202,7 +209,7 @@ class FilterTest(unittest.TestCase): ...@@ -202,7 +209,7 @@ class FilterTest(unittest.TestCase):
self.assertEquals(todolist_to_string(filtered_todos), "") self.assertEquals(todolist_to_string(filtered_todos), "")
def test_filter21(self): def test_filter22(self):
todos = load_file('data/FilterTest3.txt') todos = load_file('data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('due:=2014-11-10') otf = Filter.OrdinalTagFilter('due:=2014-11-10')
...@@ -210,7 +217,7 @@ class FilterTest(unittest.TestCase): ...@@ -210,7 +217,7 @@ class FilterTest(unittest.TestCase):
self.assertEquals(todolist_to_string(filtered_todos), "") self.assertEquals(todolist_to_string(filtered_todos), "")
def test_filter22(self): def test_filter23(self):
todos = load_file('data/FilterTest3.txt') todos = load_file('data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('due:=2014-11-99') otf = Filter.OrdinalTagFilter('due:=2014-11-99')
...@@ -218,7 +225,7 @@ class FilterTest(unittest.TestCase): ...@@ -218,7 +225,7 @@ class FilterTest(unittest.TestCase):
self.assertEquals(todolist_to_string(filtered_todos), "") self.assertEquals(todolist_to_string(filtered_todos), "")
def test_filter23(self): def test_filter24(self):
todos = load_file('data/FilterTest3.txt') todos = load_file('data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('due:=garbage') otf = Filter.OrdinalTagFilter('due:=garbage')
...@@ -226,7 +233,7 @@ class FilterTest(unittest.TestCase): ...@@ -226,7 +233,7 @@ class FilterTest(unittest.TestCase):
self.assertEquals(todolist_to_string(filtered_todos), "") self.assertEquals(todolist_to_string(filtered_todos), "")
def test_filter24(self): def test_filter25(self):
todos = load_file('data/FilterTest3.txt') todos = load_file('data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:<10') otf = Filter.OrdinalTagFilter('value:<10')
...@@ -236,7 +243,7 @@ class FilterTest(unittest.TestCase): ...@@ -236,7 +243,7 @@ class FilterTest(unittest.TestCase):
self.assertEquals(todolist_to_string(filtered_todos), self.assertEquals(todolist_to_string(filtered_todos),
todolist_to_string(reference)) todolist_to_string(reference))
def test_filter25(self): def test_filter26(self):
todos = load_file('data/FilterTest3.txt') todos = load_file('data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:<=16') otf = Filter.OrdinalTagFilter('value:<=16')
...@@ -246,7 +253,7 @@ class FilterTest(unittest.TestCase): ...@@ -246,7 +253,7 @@ class FilterTest(unittest.TestCase):
self.assertEquals(todolist_to_string(filtered_todos), self.assertEquals(todolist_to_string(filtered_todos),
todolist_to_string(reference)) todolist_to_string(reference))
def test_filter26(self): def test_filter27(self):
todos = load_file('data/FilterTest3.txt') todos = load_file('data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:<16') otf = Filter.OrdinalTagFilter('value:<16')
...@@ -256,7 +263,7 @@ class FilterTest(unittest.TestCase): ...@@ -256,7 +263,7 @@ class FilterTest(unittest.TestCase):
self.assertEquals(todolist_to_string(filtered_todos), self.assertEquals(todolist_to_string(filtered_todos),
todolist_to_string(reference)) todolist_to_string(reference))
def test_filter27(self): def test_filter28(self):
todos = load_file('data/FilterTest3.txt') todos = load_file('data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:<16a') otf = Filter.OrdinalTagFilter('value:<16a')
...@@ -264,7 +271,7 @@ class FilterTest(unittest.TestCase): ...@@ -264,7 +271,7 @@ class FilterTest(unittest.TestCase):
self.assertEquals(todolist_to_string(filtered_todos), "") self.assertEquals(todolist_to_string(filtered_todos), "")
def test_filter28(self): def test_filter29(self):
todos = load_file('data/FilterTest3.txt') todos = load_file('data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:>8') otf = Filter.OrdinalTagFilter('value:>8')
...@@ -274,7 +281,7 @@ class FilterTest(unittest.TestCase): ...@@ -274,7 +281,7 @@ class FilterTest(unittest.TestCase):
self.assertEquals(todolist_to_string(filtered_todos), self.assertEquals(todolist_to_string(filtered_todos),
todolist_to_string(reference)) todolist_to_string(reference))
def test_filter29(self): def test_filter30(self):
todos = load_file('data/FilterTest3.txt') todos = load_file('data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:>=8') otf = Filter.OrdinalTagFilter('value:>=8')
...@@ -284,7 +291,7 @@ class FilterTest(unittest.TestCase): ...@@ -284,7 +291,7 @@ class FilterTest(unittest.TestCase):
self.assertEquals(todolist_to_string(filtered_todos), self.assertEquals(todolist_to_string(filtered_todos),
todolist_to_string(reference)) todolist_to_string(reference))
def test_filter30(self): def test_filter31(self):
todos = load_file('data/FilterTest3.txt') todos = load_file('data/FilterTest3.txt')
otf = Filter.OrdinalTagFilter('value:>-8') otf = Filter.OrdinalTagFilter('value:>-8')
......
...@@ -62,7 +62,8 @@ class GrepFilter(Filter): ...@@ -62,7 +62,8 @@ class GrepFilter(Filter):
def __init__(self, p_expression, p_case_sensitive=None): def __init__(self, p_expression, p_case_sensitive=None):
super(GrepFilter, self).__init__() super(GrepFilter, self).__init__()
self.expression = p_expression # convert to string in case we receive integers
self.expression = str(p_expression)
if p_case_sensitive != None: if p_case_sensitive != None:
self.case_sensitive = p_case_sensitive self.case_sensitive = p_case_sensitive
...@@ -70,7 +71,7 @@ class GrepFilter(Filter): ...@@ -70,7 +71,7 @@ class GrepFilter(Filter):
# only be case sensitive when the expression contains at least one # only be case sensitive when the expression contains at least one
# capital character. # capital character.
self.case_sensitive = \ self.case_sensitive = \
len([c for c in p_expression if c.isupper()]) > 0 len([c for c in self.expression if c.isupper()]) > 0
def match(self, p_todo): def match(self, p_todo):
expr = self.expression expr = self.expression
......
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