Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
4ee641d9
Commit
4ee641d9
authored
Jul 20, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add filter that filters todos with uncompleted child todos.
parent
4dbcc84d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
8 deletions
+49
-8
Filter.py
Filter.py
+20
-3
test/FilterTest.py
test/FilterTest.py
+16
-5
test/data/FilterTest2-result.txt
test/data/FilterTest2-result.txt
+5
-0
test/data/FilterTest2.txt
test/data/FilterTest2.txt
+8
-0
No files found.
Filter.py
View file @
4ee641d9
class
Filter
(
object
):
# def __init__(self):
# pass
def
filter
(
self
,
p_todos
,
p_limit
=
None
):
"""
Filters a list of todos. Truncates the list after p_limit todo
...
...
@@ -56,3 +53,23 @@ class RelevanceFilter(Filter):
is_due
|=
p_todo
.
priority
()
==
'C'
and
p_todo
.
days_till_due
()
<=
14
return
p_todo
.
is_active
()
and
is_due
class
DependencyFilter
(
Filter
):
""" Matches when a todo has no unfinished child tasks. """
def
__init__
(
self
,
p_todolist
):
"""
Constructor.
Pass on a TodoList instance such that the dependencies can be
looked up.
"""
self
.
todolist
=
p_todolist
def
match
(
self
,
p_todo
):
"""
Returns True when there are no children that are uncompleted yet.
"""
children
=
self
.
todolist
.
children
(
p_todo
.
number
)
uncompleted
=
[
todo
for
todo
in
children
if
not
todo
.
is_completed
()]
return
not
uncompleted
test/FilterTest.py
View file @
4ee641d9
...
...
@@ -4,14 +4,11 @@ import datetime
import
unittest
import
Filter
from
TestFacilities
import
load_file
,
todolist_to_string
from
TestFacilities
import
load_file
,
load_file_to_raw_list
,
todolist_to_string
import
Todo
import
TodoList
class
FilterTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
# self.today = datetime.date.today()
pass
def
test_filter1
(
self
):
todo
=
Todo
.
Todo
(
"(C) Relevant"
)
relevance
=
Filter
.
RelevanceFilter
()
...
...
@@ -65,3 +62,17 @@ class FilterTest(unittest.TestCase):
self
.
assertEquals
(
todolist_to_string
(
filtered_todos
),
\
todolist_to_string
(
reference
))
def
test_filter7
(
self
):
""" Tests the dependency filter. """
todos_raw
=
load_file_to_raw_list
(
'data/FilterTest2.txt'
)
todos
=
load_file
(
'data/FilterTest2.txt'
)
todolist
=
TodoList
.
TodoList
(
todos_raw
)
depfilter
=
Filter
.
DependencyFilter
(
todolist
)
filtered_todos
=
depfilter
.
filter
(
todos
)
reference
=
load_file
(
'data/FilterTest2-result.txt'
)
self
.
assertEquals
(
todolist_to_string
(
filtered_todos
),
\
todolist_to_string
(
reference
))
test/data/FilterTest2-result.txt
0 → 100644
View file @
4ee641d9
Baz p:2
Buzz id:5
x 2014-07-20 Blob p:5
Task 2 p:6
x 2014-07-20 Task 3 p:6
test/data/FilterTest2.txt
0 → 100644
View file @
4ee641d9
Foo id:1
Bar p:1 id:2
Baz p:2
Buzz id:5
x 2014-07-20 Blob p:5
Task 1 id:6
Task 2 p:6
x 2014-07-20 Task 3 p:6
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment