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
a15654e0
Commit
a15654e0
authored
Oct 31, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement 'after', 'before' and 'partof' operators.
parent
b0eab341
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
8 deletions
+43
-8
test/DepCommandTest.py
test/DepCommandTest.py
+31
-3
topydo/lib/DepCommand.py
topydo/lib/DepCommand.py
+12
-5
No files found.
test/DepCommandTest.py
View file @
a15654e0
...
@@ -72,6 +72,34 @@ class DepCommandTest(CommandTest.CommandTest):
...
@@ -72,6 +72,34 @@ class DepCommandTest(CommandTest.CommandTest):
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
test_add6
(
self
):
command
=
DepCommand
.
DepCommand
([
"add"
,
"1"
,
"after"
,
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertTrue
(
self
.
todolist
.
todo
(
4
).
has_tag
(
'p'
,
'1'
))
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add7
(
self
):
command
=
DepCommand
.
DepCommand
([
"add"
,
"1"
,
"before"
,
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertTrue
(
self
.
todolist
.
todo
(
1
).
has_tag
(
'p'
,
'2'
))
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_add8
(
self
):
command
=
DepCommand
.
DepCommand
([
"add"
,
"1"
,
"partof"
,
"4"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertTrue
(
self
.
todolist
.
todo
(
1
).
has_tag
(
'p'
,
'2'
))
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
rm_helper
(
self
,
p_args
):
def
rm_helper
(
self
,
p_args
):
"""
"""
Helper function that checks the removal of the dependency from todo 1
Helper function that checks the removal of the dependency from todo 1
...
...
topydo/lib/DepCommand.py
View file @
a15654e0
...
@@ -51,13 +51,19 @@ class DepCommand(Command):
...
@@ -51,13 +51,19 @@ class DepCommand(Command):
to_todo
=
None
to_todo
=
None
try
:
try
:
from_todo_nr
=
convert_todo_number
(
self
.
argument
(
1
))
operator
=
self
.
argument
(
2
)
to_todo_nr
=
self
.
argument
(
2
)
if
to_todo_nr
==
'to'
:
if
operator
==
'before'
or
operator
==
'partof'
:
from_todo_nr
=
convert_todo_number
(
self
.
argument
(
3
))
to_todo_nr
=
convert_todo_number
(
self
.
argument
(
1
))
elif
operator
==
'to'
or
operator
==
'after'
:
from_todo_nr
=
convert_todo_number
(
self
.
argument
(
1
))
to_todo_nr
=
convert_todo_number
(
self
.
argument
(
3
))
to_todo_nr
=
convert_todo_number
(
self
.
argument
(
3
))
else
:
else
:
to_todo_nr
=
convert_todo_number
(
to_todo_nr
)
# the operator was omitted, assume 2nd argument is target task
# default to 'to' behavior
from_todo_nr
=
convert_todo_number
(
self
.
argument
(
1
))
to_todo_nr
=
convert_todo_number
(
self
.
argument
(
2
))
from_todo
=
self
.
todolist
.
todo
(
from_todo_nr
)
from_todo
=
self
.
todolist
.
todo
(
from_todo_nr
)
to_todo
=
self
.
todolist
.
todo
(
to_todo_nr
)
to_todo
=
self
.
todolist
.
todo
(
to_todo_nr
)
...
@@ -119,12 +125,13 @@ class DepCommand(Command):
...
@@ -119,12 +125,13 @@ class DepCommand(Command):
def
usage
(
self
):
def
usage
(
self
):
return
"""Synopsis:
return
"""Synopsis:
dep <add|rm> <NUMBER> [to] <NUMBER>
dep <add|rm> <NUMBER> [to] <NUMBER>
dep add <NUMBER> <before|partof|after> <NUMBER>
dep ls <NUMBER> to
dep ls <NUMBER> to
dep ls to <NUMBER>
dep ls to <NUMBER>
dep clean"""
dep clean"""
def
help
(
self
):
def
help
(
self
):
return
"""* add: Adds a dependency.
return
"""* add: Adds a dependency.
Using 1 before 2 creates a dependency from todo item 2 to 1.
* rm (alias: del): Removes a dependency.
* rm (alias: del): Removes a dependency.
* ls: Lists all dependencies to or from a certain todo.
* ls: Lists all dependencies to or from a certain todo.
* clean (alias: gc): Removes redundant id or p tags."""
* clean (alias: gc): Removes redundant id or p tags."""
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