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
d9b100eb
Commit
d9b100eb
authored
May 05, 2015
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #18 from mruwek/multi-depri
Remove priorities from multiple todo items at once
parents
22358bb2
c61e881a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
25 deletions
+49
-25
test/DepriCommandTest.py
test/DepriCommandTest.py
+33
-5
topydo/cli/Main.py
topydo/cli/Main.py
+1
-0
topydo/lib/DepriCommand.py
topydo/lib/DepriCommand.py
+15
-20
No files found.
test/DepriCommandTest.py
View file @
d9b100eb
...
@@ -26,20 +26,21 @@ class DepriCommandTest(CommandTest.CommandTest):
...
@@ -26,20 +26,21 @@ class DepriCommandTest(CommandTest.CommandTest):
todos
=
[
todos
=
[
"(A) Foo"
,
"(A) Foo"
,
"Bar"
,
"Bar"
,
"(B) Baz"
,
]
]
self
.
todolist
=
TodoList
(
todos
)
self
.
todolist
=
TodoList
(
todos
)
def
test_
set_prio
1
(
self
):
def
test_
depri
1
(
self
):
command
=
DepriCommand
([
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepriCommand
([
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
priority
(),
None
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
priority
(),
None
)
self
.
assertEquals
(
self
.
output
,
"Priority removed.
\
n
Foo
\
n
"
)
self
.
assertEquals
(
self
.
output
,
"Priority removed.
\
n
| 1|
Foo
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_
set_prio
2
(
self
):
def
test_
depri
2
(
self
):
command
=
DepriCommand
([
"2"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepriCommand
([
"2"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
command
.
execute
()
...
@@ -48,15 +49,26 @@ class DepriCommandTest(CommandTest.CommandTest):
...
@@ -48,15 +49,26 @@ class DepriCommandTest(CommandTest.CommandTest):
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_
set_prio
3
(
self
):
def
test_
depri
3
(
self
):
command
=
DepriCommand
([
"Foo"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepriCommand
([
"Foo"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
priority
(),
None
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
priority
(),
None
)
self
.
assertEquals
(
self
.
output
,
"Priority removed.
\
n
Foo
\
n
"
)
self
.
assertEquals
(
self
.
output
,
"Priority removed.
\
n
| 1|
Foo
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_depri4
(
self
):
command
=
DepriCommand
([
"1"
,
"Baz"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
todolist
.
todo
(
1
).
priority
(),
None
)
self
.
assertEquals
(
self
.
todolist
.
todo
(
3
).
priority
(),
None
)
self
.
assertEquals
(
self
.
output
,
"Priority removed.
\
n
| 1| Foo
\
n
Priority removed.
\
n
| 3| Baz
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_invalid1
(
self
):
def
test_invalid1
(
self
):
command
=
DepriCommand
([
"99"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepriCommand
([
"99"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
command
.
execute
()
...
@@ -65,6 +77,22 @@ class DepriCommandTest(CommandTest.CommandTest):
...
@@ -65,6 +77,22 @@ class DepriCommandTest(CommandTest.CommandTest):
self
.
assertFalse
(
self
.
output
)
self
.
assertFalse
(
self
.
output
)
self
.
assertEquals
(
self
.
errors
,
"Invalid todo number given.
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
"Invalid todo number given.
\
n
"
)
def
test_invalid2
(
self
):
command
=
DepriCommand
([
"99"
,
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
output
)
self
.
assertEquals
(
self
.
errors
,
"Invalid todo number given: 99.
\
n
"
)
def
test_invalid3
(
self
):
command
=
DepriCommand
([
"99"
,
"FooBar"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
output
)
self
.
assertEquals
(
self
.
errors
,
"Invalid todo number given: 99.
\
n
Invalid todo number given: FooBar.
\
n
"
)
def
test_empty
(
self
):
def
test_empty
(
self
):
command
=
DepriCommand
([],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
DepriCommand
([],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
command
.
execute
()
...
...
topydo/cli/Main.py
View file @
d9b100eb
...
@@ -39,6 +39,7 @@ Available commands:
...
@@ -39,6 +39,7 @@ Available commands:
* append (app)
* append (app)
* del (rm)
* del (rm)
* dep
* dep
* depri
* do
* do
* edit
* edit
* ical
* ical
...
...
topydo/lib/DepriCommand.py
View file @
d9b100eb
...
@@ -14,10 +14,10 @@
...
@@ -14,10 +14,10 @@
# 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/>.
from
topydo.lib.
Command
import
Command
,
InvalidCommandArgument
from
topydo.lib.
MultiCommand
import
MultiCommand
from
topydo.lib.
TodoListBase
import
InvalidTodoException
from
topydo.lib.
PrettyPrinterFilter
import
PrettyPrinterNumbers
class
DepriCommand
(
Command
):
class
DepriCommand
(
Multi
Command
):
def
__init__
(
self
,
p_args
,
p_todolist
,
def
__init__
(
self
,
p_args
,
p_todolist
,
p_out
=
lambda
a
:
None
,
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
...
@@ -25,28 +25,23 @@ class DepriCommand(Command):
...
@@ -25,28 +25,23 @@ class DepriCommand(Command):
super
(
DepriCommand
,
self
).
__init__
(
super
(
DepriCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
def
execute
(
self
):
self
.
get_todos
(
self
.
args
)
if
not
super
(
DepriCommand
,
self
).
execute
():
return
False
todo
=
None
def
execute_multi_specific
(
self
):
try
:
try
:
todo
=
self
.
todolist
.
todo
(
self
.
argument
(
0
))
self
.
printer
.
add_filter
(
PrettyPrinterNumbers
(
self
.
todolist
))
if
todo
.
priority
()
!=
None
:
for
todo
in
self
.
todos
:
self
.
todolist
.
set_priority
(
todo
,
None
)
if
todo
.
priority
()
!=
None
:
self
.
out
(
"Priority removed."
)
self
.
todolist
.
set_priority
(
todo
,
None
)
self
.
out
(
self
.
printer
.
print_todo
(
todo
))
self
.
out
(
"Priority removed."
)
except
InvalidCommandArgument
:
self
.
out
(
self
.
printer
.
print_todo
(
todo
))
except
IndexError
:
self
.
error
(
self
.
usage
())
self
.
error
(
self
.
usage
())
except
(
InvalidTodoException
):
if
not
todo
:
self
.
error
(
"Invalid todo number given."
)
else
:
self
.
error
(
self
.
usage
())
def
usage
(
self
):
def
usage
(
self
):
return
"""Synopsis: depri <NUMBER
>
"""
return
"""Synopsis: depri <NUMBER
1> [<NUMBER2> ...]
"""
def
help
(
self
):
def
help
(
self
):
return
"""Removes the priority of the given todo item."""
return
"""Removes the priority of the given todo item
(s)
."""
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