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
a9f29074
Commit
a9f29074
authored
Feb 27, 2015
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5 from mruwek/multi-pri
Allow multiple tasks to be prioritized at once
parents
2a9be13f
0593bfbd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
18 deletions
+31
-18
test/PriorityCommandTest.py
test/PriorityCommandTest.py
+8
-0
topydo/lib/PriorityCommand.py
topydo/lib/PriorityCommand.py
+23
-18
No files found.
test/PriorityCommandTest.py
View file @
a9f29074
...
@@ -62,6 +62,14 @@ class PriorityCommandTest(CommandTest.CommandTest):
...
@@ -62,6 +62,14 @@ class PriorityCommandTest(CommandTest.CommandTest):
self
.
assertEquals
(
self
.
output
,
"(A) Foo
\
n
"
)
self
.
assertEquals
(
self
.
output
,
"(A) Foo
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_set_prio5
(
self
):
command
=
PriorityCommand
([
"Foo"
,
"2"
,
"C"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
"Priority changed from A to C
\
n
(C) Foo
\
n
Priority set to C.
\
n
(C) Bar
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_invalid1
(
self
):
def
test_invalid1
(
self
):
command
=
PriorityCommand
([
"99"
,
"A"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
PriorityCommand
([
"99"
,
"A"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
command
.
execute
()
...
...
topydo/lib/PriorityCommand.py
View file @
a9f29074
...
@@ -30,38 +30,43 @@ class PriorityCommand(Command):
...
@@ -30,38 +30,43 @@ class PriorityCommand(Command):
if
not
super
(
PriorityCommand
,
self
).
execute
():
if
not
super
(
PriorityCommand
,
self
).
execute
():
return
False
return
False
number
=
None
number
s
=
None
priority
=
None
priority
=
None
try
:
try
:
number
=
self
.
argument
(
0
)
numbers
=
self
.
args
[:
-
1
]
priority
=
self
.
argument
(
1
)
priority
=
self
.
args
[
-
1
]
todo
=
self
.
todolist
.
todo
(
number
)
if
is_valid_priority
(
priority
):
if
len
(
numbers
)
>
0
:
old_priority
=
todo
.
priority
()
todos
=
[
self
.
todolist
.
todo
(
number
)
for
number
in
numbers
]
self
.
todolist
.
set_priority
(
todo
,
priority
)
if
old_priority
and
priority
and
old_priority
!=
priority
:
if
is_valid_priority
(
priority
):
self
.
out
(
"Priority changed from {} to {}"
.
format
(
for
todo
in
todos
:
old_priority
,
priority
))
old_priority
=
todo
.
priority
()
elif
not
old_priority
:
self
.
todolist
.
set_priority
(
todo
,
priority
)
self
.
out
(
"Priority set to {}."
.
format
(
priority
))
self
.
out
(
self
.
printer
.
print_todo
(
todo
))
if
old_priority
and
priority
and
old_priority
!=
priority
:
self
.
out
(
"Priority changed from {} to {}"
.
format
(
old_priority
,
priority
))
elif
not
old_priority
:
self
.
out
(
"Priority set to {}."
.
format
(
priority
))
self
.
out
(
self
.
printer
.
print_todo
(
todo
))
else
:
self
.
error
(
"Invalid priority given."
)
else
:
else
:
self
.
error
(
"Invalid priority given."
)
self
.
error
(
self
.
usage
()
)
except
InvalidCommandArgument
:
except
(
IndexError
,
InvalidCommandArgument
)
:
self
.
error
(
self
.
usage
())
self
.
error
(
self
.
usage
())
except
(
InvalidTodoException
):
except
(
InvalidTodoException
):
if
number
and
priority
:
if
len
(
numbers
)
>
0
and
priority
:
self
.
error
(
"Invalid todo number given."
)
self
.
error
(
"Invalid todo number given."
)
else
:
else
:
self
.
error
(
self
.
usage
())
self
.
error
(
self
.
usage
())
def
usage
(
self
):
def
usage
(
self
):
return
"""Synopsis: pri <NUMBER
>
<PRIORITY>"""
return
"""Synopsis: pri <NUMBER
1> [<NUMBER2> ...]
<PRIORITY>"""
def
help
(
self
):
def
help
(
self
):
return
"""
\
return
"""
\
Sets the priority of todo
the given number
to the given priority.
Sets the priority of todo
(s) the given number(s)
to the given priority.
"""
"""
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