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
7ff76a2d
Commit
7ff76a2d
authored
Jul 13, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add function to clean stale dependencies.
parent
8c47b843
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
TodoList.py
TodoList.py
+18
-0
test/TodoListTest.py
test/TodoListTest.py
+15
-0
No files found.
TodoList.py
View file @
7ff76a2d
...
...
@@ -200,6 +200,24 @@ class TodoList(object):
self._depgraph.outgoing_neighbors(p_number, not p_only_direct)
return [self.todo(child) for child in children]
def clean_dependencies(self):
"""
Cleans the dependency graph.
This is achieved by performing a transitive reduction on the dependency
graph and removing unused dependency ids from the graph (in that
order).
"""
def clean_by_tag(tag_name):
for todo in [todo for todo in self._todos if todo.has_tag(tag_name)]:
value = todo.tag_value(tag_name)
if not self._depgraph.has_edge_id(value):
todo.remove_tag(tag_name, value)
self._depgraph.transitively_reduce()
clean_by_tag('
p
')
clean_by_tag('
id
')
def __str__(self):
return '
\
n
'.join(pretty_print(self._todos))
test/TodoListTest.py
View file @
7ff76a2d
...
...
@@ -180,3 +180,18 @@ class TodoListDependencyTester(unittest.TestCase):
self
.
assertEqual
(
self
.
todolist
.
todo
(
1
).
source
(),
'Foo id:1'
)
self
.
assertEqual
(
self
.
todolist
.
todo
(
2
).
source
(),
'Bar p:1'
)
class
TodoListCleanDependencyTester
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
todolist
=
TodoList
.
TodoList
([])
self
.
todolist
.
add
(
"Bar p:1"
)
self
.
todolist
.
add
(
"Baz p:1 id:2"
)
self
.
todolist
.
add
(
"Buzz p:2"
)
def
test_clean_dependencies
(
self
):
self
.
todolist
.
clean_dependencies
()
self
.
assertFalse
(
self
.
todolist
.
todo
(
1
).
has_tag
(
'p'
))
self
.
assertFalse
(
self
.
todolist
.
todo
(
2
).
has_tag
(
'p'
))
self
.
assertTrue
(
self
.
todolist
.
todo
(
2
).
has_tag
(
'id'
,
'2'
))
self
.
assertTrue
(
self
.
todolist
.
todo
(
3
).
has_tag
(
'p'
,
'2'
))
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