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
43da2315
Commit
43da2315
authored
Mar 31, 2015
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12 from mruwek/append_parent_contexts
Append parent contexts
parents
5718e113
95baa9ef
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
0 deletions
+44
-0
test/AddCommandTest.py
test/AddCommandTest.py
+20
-0
test/data/todolist-uid-contexts.conf
test/data/todolist-uid-contexts.conf
+5
-0
topydo.conf
topydo.conf
+2
-0
topydo/lib/Config.py
topydo/lib/Config.py
+7
-0
topydo/lib/TodoList.py
topydo/lib/TodoList.py
+10
-0
No files found.
test/AddCommandTest.py
View file @
43da2315
...
...
@@ -192,6 +192,26 @@ class AddCommandTest(CommandTest.CommandTest):
self
.
assertEquals
(
self
.
output
,
"|5dh| {today} Bar p:1 +Project
\
n
|5dh| {today} Bar +Project
\
n
"
.
format
(
today
=
self
.
today
))
def
test_add_dep10
(
self
):
"""
The text ID shown after adding and after an 'ls' must be equal."
By appending the parent's contexts, the textual ID may change.
"""
config
(
"test/data/todolist-uid-contexts.conf"
)
# pass identitiy function to for writing output, we're not interested
# in this output
command
=
AddCommand
.
AddCommand
([
"Foo @Context"
],
self
.
todolist
,
lambda
t
:
t
,
self
.
error
)
command
.
execute
()
command
=
AddCommand
.
AddCommand
([
"Bar before:x2k"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
command
=
ListCommand
.
ListCommand
([
"Bar"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEquals
(
self
.
output
,
"|5dc| {today} Bar p:1 @Context
\
n
|5dc| {today} Bar @Context
\
n
"
.
format
(
today
=
self
.
today
))
def
test_add_reldate1
(
self
):
command
=
AddCommand
.
AddCommand
([
"Foo due:today"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
test/data/todolist-uid-contexts.conf
0 → 100644
View file @
43da2315
[
topydo
]
identifiers
=
text
[
dep
]
append_parent_contexts
=
1
topydo.conf
View file @
43da2315
...
...
@@ -28,3 +28,5 @@ ignore_weekends = 1
[
dep
]
;
Add
parent
projects
when
adding
sub
todo
items
append_parent_projects
=
0
;
Add
parent
contexts
when
adding
sub
todo
items
append_parent_contexts
=
0
topydo/lib/Config.py
View file @
43da2315
...
...
@@ -61,6 +61,7 @@ class _Config:
# dep
'append_parent_projects'
:
'0'
,
'append_parent_contexts'
:
'0'
,
}
self
.
config
=
{}
...
...
@@ -148,6 +149,12 @@ class _Config:
except
ValueError
:
return
self
.
defaults
[
'append_parent_projects'
]
==
'1'
def
append_parent_contexts
(
self
):
try
:
return
self
.
cp
.
getboolean
(
'dep'
,
'append_parent_contexts'
)
except
ValueError
:
return
self
.
defaults
[
'append_parent_contexts'
]
==
'1'
def
_get_tag
(
self
,
p_tag
):
try
:
return
self
.
config
[
p_tag
]
...
...
topydo/lib/TodoList.py
View file @
43da2315
...
...
@@ -141,6 +141,15 @@ class TodoList(TodoListBase):
for
project
in
p_from_todo
.
projects
()
-
p_to_todo
.
projects
():
self
.
append
(
p_to_todo
,
"+{}"
.
format
(
project
))
def
append_contexts_to_subtodo
():
"""
Appends contexts in the parent todo item that are not present in
the sub todo item.
"""
if
config
().
append_parent_contexts
():
for
context
in
p_from_todo
.
contexts
()
-
p_to_todo
.
contexts
():
self
.
append
(
p_to_todo
,
"@{}"
.
format
(
context
))
if
p_from_todo
!=
p_to_todo
and
not
self
.
_depgraph
.
has_edge
(
hash
(
p_from_todo
),
hash
(
p_to_todo
)):
...
...
@@ -155,6 +164,7 @@ class TodoList(TodoListBase):
self
.
_depgraph
.
add_edge
(
hash
(
p_from_todo
),
hash
(
p_to_todo
),
dep_id
)
self
.
_update_parent_cache
()
append_projects_to_subtodo
()
append_contexts_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