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
a7c495bf
Commit
a7c495bf
authored
Aug 30, 2016
by
Bram Schoenmakers
Committed by
GitHub
Aug 30, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #131 from MinchinWeb/hidden-tag
Add HiddenTagFilter
parents
6cecc616
6408ee56
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
9 deletions
+46
-9
test/data/ListCommandTest.txt
test/data/ListCommandTest.txt
+1
-0
test/test_list_command.py
test/test_list_command.py
+3
-3
topydo/commands/ListCommand.py
topydo/commands/ListCommand.py
+9
-4
topydo/lib/Config.py
topydo/lib/Config.py
+8
-0
topydo/lib/Filter.py
topydo/lib/Filter.py
+25
-2
No files found.
test/data/ListCommandTest.txt
View file @
a7c495bf
...
...
@@ -5,3 +5,4 @@
(C) 13 + 29 = 42
x 2014-12-12 Completed but with date:2014-12-12
hidden item h:1
test/test_list_command.py
View file @
a7c495bf
...
...
@@ -72,7 +72,7 @@ class ListCommandTest(CommandTest):
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
dirty
)
self
.
assertEqual
(
self
.
output
,
"| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project
\
n
| 3| (C) Baz @Context1 +Project1 key:value
\
n
| 4| (C) Drink beer @ home
\
n
| 5| (C) 13 + 29 = 42
\
n
| 2| (D) Bar @Context1 +Project2
\
n
| 6| x 2014-12-12 Completed but with date:2014-12-12
\
n
"
)
self
.
assertEqual
(
self
.
output
,
"| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project
\
n
| 3| (C) Baz @Context1 +Project1 key:value
\
n
| 4| (C) Drink beer @ home
\
n
| 5| (C) 13 + 29 = 42
\
n
| 2| (D) Bar @Context1 +Project2
\
n
|
7| hidden item h:1
\
n
|
6| x 2014-12-12 Completed but with date:2014-12-12
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_list06
(
self
):
...
...
@@ -147,7 +147,7 @@ class ListCommandTest(CommandTest):
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
dirty
)
self
.
assertEqual
(
self
.
output
,
"| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project
\
n
| 3| (C) Baz @Context1 +Project1 key:value
\
n
| 4| (C) Drink beer @ home
\
n
| 5| (C) 13 + 29 = 42
\
n
| 6| x 2014-12-12 Completed but with date:2014-12-12
\
n
"
)
self
.
assertEqual
(
self
.
output
,
"| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project
\
n
| 3| (C) Baz @Context1 +Project1 key:value
\
n
| 4| (C) Drink beer @ home
\
n
| 5| (C) 13 + 29 = 42
\
n
|
7| hidden item h:1
\
n
|
6| x 2014-12-12 Completed but with date:2014-12-12
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_list14
(
self
):
...
...
@@ -275,7 +275,7 @@ class ListCommandTest(CommandTest):
command
=
ListCommand
([
"-x"
,
"-n"
,
"foo"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEqual
(
self
.
output
,
"| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project
\
n
| 3| (C) Baz @Context1 +Project1 key:value
\
n
| 4| (C) Drink beer @ home
\
n
| 5| (C) 13 + 29 = 42
\
n
| 2| (D) Bar @Context1 +Project2
\
n
| 6| x 2014-12-12 Completed but with date:2014-12-12
\
n
"
)
self
.
assertEqual
(
self
.
output
,
"| 1| (C) 2015-11-05 Foo @Context2 Not@Context +Project1 Not+Project
\
n
| 3| (C) Baz @Context1 +Project1 key:value
\
n
| 4| (C) Drink beer @ home
\
n
| 5| (C) 13 + 29 = 42
\
n
| 2| (D) Bar @Context1 +Project2
\
n
|
7| hidden item h:1
\
n
|
6| x 2014-12-12 Completed but with date:2014-12-12
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
""
)
def
test_list36
(
self
):
...
...
topydo/commands/ListCommand.py
View file @
a7c495bf
...
...
@@ -20,7 +20,7 @@ import os
from
topydo.lib.Config
import
config
from
topydo.lib.ExpressionCommand
import
ExpressionCommand
from
topydo.lib.Filter
import
InstanceFilter
from
topydo.lib.Filter
import
HiddenTagFilter
,
InstanceFilter
from
topydo.lib.PrettyPrinter
import
pretty_printer_factory
from
topydo.lib.prettyprinters.Format
import
PrettyPrinterFormatFilter
from
topydo.lib.TodoListBase
import
InvalidTodoException
...
...
@@ -93,8 +93,9 @@ class ListCommand(ExpressionCommand):
def
_filters
(
self
):
"""
Additional filters to select particular todo items given with the -i
flag.
Additional filters to:
- select particular todo items given with the -i flag,
- hide appropriately tagged items in the absense of the -x flag.
"""
filters
=
super
().
_filters
()
...
...
@@ -112,6 +113,9 @@ class ListCommand(ExpressionCommand):
todos
=
[
get_todo
(
i
)
for
i
in
self
.
ids
]
filters
.
append
(
InstanceFilter
(
todos
))
if
not
self
.
show_all
:
filters
.
append
(
HiddenTagFilter
())
return
filters
def
_print
(
self
):
...
...
@@ -238,5 +242,6 @@ When an EXPRESSION is given, only the todos matching that EXPRESSION are shown.
-N : Limit number of items displayed such that they fit on the terminal.
-s : Sort the list according to a SORT EXPRESSION. Defaults to the expression
in the configuration.
-x : Show all todos (i.e. do not filter on dependencies or relevance).
\
-x : Show all todos (i.e. do not filter on dependencies, relevance, or hidden
status).
\
"""
topydo/lib/Config.py
View file @
a7c495bf
...
...
@@ -77,6 +77,7 @@ class _Config:
'ls'
:
{
'hide_tags'
:
'id,p,ical'
,
'hidden_item_tags'
:
'h,hide'
,
'indent'
:
'0'
,
'list_limit'
:
'-1'
,
'list_format'
:
'|%I| %x %{(}p{)} %c %s %k %{due:}d %{t:}t'
,
...
...
@@ -311,6 +312,13 @@ class _Config:
return
[]
if
hidden_tags
==
''
else
[
tag
.
strip
()
for
tag
in
hidden_tags
.
split
(
','
)]
def
hidden_item_tags
(
self
):
""" Returns a list of tags which hide an item from the 'ls' output. """
hidden_item_tags
=
self
.
cp
.
get
(
'ls'
,
'hidden_item_tags'
)
# pylint: disable=no-member
return
[]
if
hidden_item_tags
==
''
else
[
tag
.
strip
()
for
tag
in
hidden_item_tags
.
split
(
','
)]
def
priority_color
(
self
,
p_priority
):
"""
Returns a dict with priorities as keys and color numbers as value.
...
...
topydo/lib/Filter.py
View file @
a7c495bf
...
...
@@ -16,6 +16,7 @@
import
re
from
topydo.lib.Config
import
config
from
topydo.lib.RelativeDate
import
relative_date_to_date
from
topydo.lib.Utils
import
date_string_to_date
...
...
@@ -91,8 +92,8 @@ class RelevanceFilter(Filter):
The item has not been completed AND
The start date is blank, today or in the past, AND
The priority is 'A'
or the priority is B with due date within 30 days
or
the priority is
C
with due date within 14 days.
The priority is 'A'
, or the priority is 'B' with due date within 30 days,
or
the priority is
'C'
with due date within 14 days.
"""
def
match
(
self
,
p_todo
):
...
...
@@ -154,6 +155,28 @@ class InstanceFilter(Filter):
return
False
class
HiddenTagFilter
(
Filter
):
def
__init__
(
self
):
"""
Constructor.
A filter which hides items marked with the approriate tag.
"""
super
().
__init__
()
def
match
(
self
,
p_todo
):
"""
Returns True when p_todo doesn't have a tag to mark it as hidden.
"""
for
my_tag
in
config
().
hidden_item_tags
():
my_values
=
p_todo
.
tag_values
(
my_tag
)
for
my_value
in
my_values
:
if
not
my_value
in
(
0
,
'0'
,
False
,
'False'
):
return
False
return
True
class
LimitFilter
(
Filter
):
def
__init__
(
self
,
p_limit
):
super
().
__init__
()
...
...
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