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
895a99bb
Commit
895a99bb
authored
Jun 18, 2015
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pri command: also allow (A), [A] or ([*A*]) as a priority.
Priority Aa or AB is (still) not allowed.
parent
870fa601
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
2 deletions
+38
-2
test/PriorityCommandTest.py
test/PriorityCommandTest.py
+32
-0
topydo/commands/PriorityCommand.py
topydo/commands/PriorityCommand.py
+6
-2
No files found.
test/PriorityCommandTest.py
View file @
895a99bb
...
...
@@ -74,6 +74,15 @@ class PriorityCommandTest(CommandTest):
self
.
assertEqual
(
self
.
output
,
"Priority changed from A to C
\
n
| 1| (C) Foo
\
n
Priority set to C.
\
n
| 2| (C) Bar
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_set_prio6
(
self
):
""" Allow priority to be set including parentheses. """
command
=
PriorityCommand
([
"Foo"
,
"2"
,
"(C)"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
"Priority changed from A to C
\
n
| 1| (C) Foo
\
n
Priority set to C.
\
n
| 2| (C) Bar
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_expr_prio1
(
self
):
command
=
PriorityCommand
([
"-e"
,
"@test"
,
"C"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
None
)
command
.
execute
()
...
...
@@ -174,6 +183,29 @@ class PriorityCommandTest(CommandTest):
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
u
(
"Invalid todo number given: Fo
\
u00d3
B
\
u0105
r.
\
n
"
))
def
test_invalid8
(
self
):
"""
Test that there's only one capital surrounded by non-word
characters that makes up a priority.
"""
command
=
PriorityCommand
([
"2"
,
"(Aa)"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
"Invalid priority given.
\
n
"
)
def
test_invalid9
(
self
):
"""
Test that there's only one capital surrounded by non-word
characters that makes up a priority.
"""
command
=
PriorityCommand
([
"2"
,
"Aa"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
"Invalid priority given.
\
n
"
)
def
test_empty
(
self
):
command
=
PriorityCommand
([],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
topydo/commands/PriorityCommand.py
View file @
895a99bb
...
...
@@ -14,6 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
re
from
topydo.lib.MultiCommand
import
MultiCommand
from
topydo.lib.PrettyPrinterFilter
import
PrettyPrinterNumbers
from
topydo.lib.Utils
import
is_valid_priority
...
...
@@ -29,9 +31,11 @@ class PriorityCommand(MultiCommand):
self
.
last_argument
=
True
def
_execute_multi_specific
(
self
):
priority
=
None
def
normalize_priority
(
p_priority
):
match
=
re
.
search
(
r'\b([A-Z])\b'
,
p_priority
)
return
match
.
group
(
1
)
if
match
else
p_priority
priority
=
self
.
args
[
-
1
]
priority
=
normalize_priority
(
self
.
args
[
-
1
])
self
.
printer
.
add_filter
(
PrettyPrinterNumbers
(
self
.
todolist
))
if
is_valid_priority
(
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