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
0cbfc6a8
Commit
0cbfc6a8
authored
Dec 09, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copy projects from parent to new sub todo items.
parent
4c7e5c54
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
2 deletions
+61
-2
test/TodoListTest.py
test/TodoListTest.py
+29
-0
test/data/config3
test/data/config3
+2
-0
topydo.conf
topydo.conf
+4
-0
topydo/lib/Config.py
topydo/lib/Config.py
+10
-1
topydo/lib/TodoList.py
topydo/lib/TodoList.py
+16
-1
No files found.
test/TodoListTest.py
View file @
0cbfc6a8
...
...
@@ -230,6 +230,9 @@ class TodoListDependencyTester(TopydoTest.TopydoTest):
self
.
todolist
.
add
(
"Baz p:1 id:2"
)
self
.
todolist
.
add
(
"Buzz p:2"
)
self
.
todolist
.
add
(
"Fnord"
)
self
.
todolist
.
add
(
"Something with +Project"
)
self
.
todolist
.
add
(
"Another one with +Project"
)
self
.
todolist
.
add
(
"Todo with +AnotherProject"
)
def
test_check_dep
(
self
):
children
=
self
.
todolist
.
children
(
self
.
todolist
.
todo
(
1
))
...
...
@@ -279,6 +282,32 @@ class TodoListDependencyTester(TopydoTest.TopydoTest):
self
.
assertTrue
(
todo4
.
has_tag
(
'id'
,
'4'
))
self
.
assertTrue
(
todo1
.
has_tag
(
'p'
,
'4'
))
def
test_add_dep3
(
self
):
"""
Test that projects are not added double.
"""
todo6
=
self
.
todolist
.
todo
(
6
)
todo7
=
self
.
todolist
.
todo
(
7
)
projects
=
todo7
.
projects
().
copy
()
self
.
todolist
.
add_dependency
(
todo6
,
todo7
)
self
.
assertEquals
(
projects
,
todo7
.
projects
())
def
test_add_dep4
(
self
):
"""
Test that a new project is added to the sub todo.
"""
config
(
"test/data/config3"
)
todo6
=
self
.
todolist
.
todo
(
6
)
todo8
=
self
.
todolist
.
todo
(
8
)
self
.
todolist
.
add_dependency
(
todo6
,
todo8
)
self
.
assertEquals
(
set
([
"Project"
,
"AnotherProject"
]),
todo8
.
projects
())
def
test_remove_dep1
(
self
):
from_todo
=
self
.
todolist
.
todo
(
3
)
to_todo
=
self
.
todolist
.
todo
(
4
)
...
...
test/data/config3
0 → 100644
View file @
0cbfc6a8
[dep]
append_parent_projects = 1
topydo.conf
View file @
0cbfc6a8
...
...
@@ -23,3 +23,7 @@ sort_string = desc:importance,due,desc:priority
;
For
calculating
importance
ignore_weekends
=
1
[
dep
]
;
Add
parent
projects
when
adding
sub
todo
items
append_parent_projects
=
0
topydo/lib/Config.py
View file @
0cbfc6a8
...
...
@@ -33,7 +33,7 @@ class _Config:
If p_path is given, that is the only configuration file that will be
read.
"""
self
.
sections
=
[
'topydo'
,
'tags'
,
'sort'
,
'ls'
]
self
.
sections
=
[
'topydo'
,
'tags'
,
'sort'
,
'ls'
,
'dep'
]
self
.
defaults
=
{
# topydo
...
...
@@ -57,6 +57,9 @@ class _Config:
'keep_sorted'
:
'0'
,
'sort_string'
:
'desc:importance,due,desc:priority'
,
'ignore_weekends'
:
'1'
,
# dep
'append_parent_projects'
:
'0'
,
}
self
.
config
=
{}
...
...
@@ -138,6 +141,12 @@ class _Config:
except
ValueError
:
return
self
.
defaults
[
'ignore_weekends'
]
==
'1'
def
append_parent_projects
(
self
):
try
:
return
self
.
cp
.
getboolean
(
'dep'
,
'append_parent_projects'
)
except
ValueError
:
return
self
.
defaults
[
'append_parent_projects'
]
==
'1'
def
_get_tag
(
self
,
p_tag
):
try
:
return
self
.
config
[
p_tag
]
...
...
topydo/lib/TodoList.py
View file @
0cbfc6a8
...
...
@@ -18,6 +18,7 @@
A list of todo items.
"""
from
topydo.lib.Config
import
config
from
topydo.lib.Graph
import
DirectedGraph
from
topydo.lib.TodoListBase
import
TodoListBase
...
...
@@ -116,7 +117,20 @@ class TodoList(TodoListBase):
return
str
(
new_id
)
if
p_from_todo
!=
p_to_todo
and
not
self
.
_depgraph
.
has_edge
(
hash
(
p_from_todo
),
hash
(
p_to_todo
)):
def
append_projects_to_subtodo
():
"""
Appends projects in the parent todo item that are not present in
the sub todo item.
"""
if
config
().
append_parent_projects
():
for
project
in
p_from_todo
.
projects
()
-
p_to_todo
.
projects
():
src
=
p_to_todo
.
source
()
src
+=
" +{}"
.
format
(
project
)
p_to_todo
.
set_source_text
(
src
)
if
p_from_todo
!=
p_to_todo
and
not
self
.
_depgraph
.
has_edge
(
hash
(
p_from_todo
),
hash
(
p_to_todo
)):
dep_id
=
None
if
p_from_todo
.
has_tag
(
'id'
):
dep_id
=
p_from_todo
.
tag_value
(
'id'
)
...
...
@@ -127,6 +141,7 @@ class TodoList(TodoListBase):
p_to_todo
.
add_tag
(
'p'
,
dep_id
)
self
.
_depgraph
.
add_edge
(
hash
(
p_from_todo
),
hash
(
p_to_todo
),
dep_id
)
self
.
_update_parent_cache
()
append_projects_to_subtodo
()
self
.
dirty
=
True
def
remove_dependency
(
self
,
p_from_todo
,
p_to_todo
):
...
...
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