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
0bca00a7
Commit
0bca00a7
authored
Oct 30, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Arguments that start with - are a negation.
parent
1f3269c5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
10 deletions
+36
-10
lib/ListCommand.py
lib/ListCommand.py
+26
-8
test/ListCommandTest.py
test/ListCommandTest.py
+10
-2
No files found.
lib/ListCommand.py
View file @
0bca00a7
...
@@ -38,21 +38,39 @@ class ListCommand(Command.Command):
...
@@ -38,21 +38,39 @@ class ListCommand(Command.Command):
elif
o
==
'-s'
:
elif
o
==
'-s'
:
self
.
sort_expression
=
a
self
.
sort_expression
=
a
return
args
self
.
args
=
args
def
_filters
(
self
):
filters
=
[]
def
grep_filters
():
for
arg
in
self
.
args
:
if
len
(
arg
)
>
1
and
arg
[
0
]
==
'-'
:
# when a word starts with -, exclude it
grep
=
Filter
.
NegationFilter
(
Filter
.
GrepFilter
(
arg
[
1
:]))
else
:
grep
=
Filter
.
GrepFilter
(
arg
)
filters
.
append
(
grep
)
if
not
self
.
show_all
:
filters
.
append
(
Filter
.
DependencyFilter
(
self
.
todolist
))
filters
.
append
(
Filter
.
RelevanceFilter
())
grep_filters
()
filters
.
append
(
Filter
.
LimitFilter
(
Config
.
LIST_LIMIT
))
return
filters
def
execute
(
self
):
def
execute
(
self
):
if
not
super
(
ListCommand
,
self
).
execute
():
if
not
super
(
ListCommand
,
self
).
execute
():
return
False
return
False
args
=
self
.
_process_flags
()
self
.
_process_flags
()
sorter
=
Sorter
.
Sorter
(
self
.
sort_expression
)
sorter
=
Sorter
.
Sorter
(
self
.
sort_expression
)
filters
=
[]
if
self
.
show_all
else
[
Filter
.
DependencyFilter
(
self
.
todolist
),
Filter
.
RelevanceFilter
()]
filters
=
self
.
_filters
()
for
arg
in
args
:
filters
.
append
(
Filter
.
GrepFilter
(
arg
))
filters
.
append
(
Filter
.
LimitFilter
(
Config
.
LIST_LIMIT
))
self
.
out
(
self
.
todolist
.
view
(
sorter
,
filters
).
pretty_print
())
self
.
out
(
self
.
todolist
.
view
(
sorter
,
filters
).
pretty_print
())
...
...
test/ListCommandTest.py
View file @
0bca00a7
...
@@ -71,14 +71,22 @@ class ListCommandTest(CommandTest.CommandTest):
...
@@ -71,14 +71,22 @@ class ListCommandTest(CommandTest.CommandTest):
self
.
assertEquals
(
self
.
errors
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_list8
(
self
):
def
test_list8
(
self
):
command
=
ListCommand
.
ListCommand
([
"-
y
"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
=
ListCommand
.
ListCommand
([
"-
project1
"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
output
,
"
4 (C) Drink beer @ home
\
n
5 (C) 13 + 29 = 42
\
n
2 (D) Bar @Context1 +Project2 p:1
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_list9
(
self
):
def
test_list9
(
self
):
command
=
ListCommand
.
ListCommand
([
"-project1"
,
"-Drink"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
" 5 (C) 13 + 29 = 42
\
n
2 (D) Bar @Context1 +Project2 p:1
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_list10
(
self
):
command
=
ListCommand
.
ListCommand
([
"text1"
,
"2"
],
self
.
todolist
,
self
.
out
,
self
.
errors
)
command
=
ListCommand
.
ListCommand
([
"text1"
,
"2"
],
self
.
todolist
,
self
.
out
,
self
.
errors
)
command
.
execute
()
command
.
execute
()
...
...
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