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
Hide 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
# Topydo - A todo.txt client written in Python.
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
# Copyright (C) 2014 Bram Schoenmakers <me@bramschoenmakers.nl>
#
#
# This program is free software: you can redistribute it and/or modify
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
...
@@ -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