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
43c6beee
Commit
43c6beee
authored
Nov 23, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various pylint fixes.
parent
f56bd7e2
Changes
25
Show whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
183 additions
and
112 deletions
+183
-112
topydo/lib/AddCommand.py
topydo/lib/AddCommand.py
+5
-2
topydo/lib/AppendCommand.py
topydo/lib/AppendCommand.py
+5
-2
topydo/lib/ArchiveCommand.py
topydo/lib/ArchiveCommand.py
+3
-3
topydo/lib/Command.py
topydo/lib/Command.py
+3
-3
topydo/lib/Config.py
topydo/lib/Config.py
+2
-2
topydo/lib/DCommand.py
topydo/lib/DCommand.py
+19
-13
topydo/lib/DeleteCommand.py
topydo/lib/DeleteCommand.py
+2
-1
topydo/lib/DepCommand.py
topydo/lib/DepCommand.py
+9
-5
topydo/lib/DepriCommand.py
topydo/lib/DepriCommand.py
+2
-1
topydo/lib/DoCommand.py
topydo/lib/DoCommand.py
+5
-2
topydo/lib/Filter.py
topydo/lib/Filter.py
+6
-0
topydo/lib/ListCommand.py
topydo/lib/ListCommand.py
+15
-11
topydo/lib/ListContextCommand.py
topydo/lib/ListContextCommand.py
+7
-6
topydo/lib/ListProjectCommand.py
topydo/lib/ListProjectCommand.py
+7
-6
topydo/lib/PostponeCommand.py
topydo/lib/PostponeCommand.py
+10
-7
topydo/lib/PrettyPrinter.py
topydo/lib/PrettyPrinter.py
+6
-4
topydo/lib/PriorityCommand.py
topydo/lib/PriorityCommand.py
+5
-2
topydo/lib/RelativeDate.py
topydo/lib/RelativeDate.py
+15
-4
topydo/lib/SortCommand.py
topydo/lib/SortCommand.py
+5
-3
topydo/lib/Sorter.py
topydo/lib/Sorter.py
+5
-5
topydo/lib/TagCommand.py
topydo/lib/TagCommand.py
+15
-9
topydo/lib/TodoList.py
topydo/lib/TodoList.py
+5
-2
topydo/lib/TodoListBase.py
topydo/lib/TodoListBase.py
+2
-1
topydo/lib/TodoParser.py
topydo/lib/TodoParser.py
+21
-14
topydo/lib/View.py
topydo/lib/View.py
+4
-4
No files found.
topydo/lib/AddCommand.py
View file @
43c6beee
...
...
@@ -30,8 +30,10 @@ class AddCommand(Command.Command):
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
lambda
a
:
None
):
super
(
AddCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
AddCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
self
.
text
=
' '
.
join
(
p_args
)
self
.
todo
=
None
def
_preprocess_input_todo
(
self
):
"""
...
...
@@ -102,7 +104,8 @@ class AddCommand(Command.Command):
return
"""Synopsis: add <text>"""
def
help
(
self
):
return
"""This subcommand automatically adds the creation date to the added item.
return
"""
\
This subcommand automatically adds the creation date to the added item.
<text> may contain:
...
...
topydo/lib/AppendCommand.py
View file @
43c6beee
...
...
@@ -23,7 +23,8 @@ class AppendCommand(Command):
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
lambda
a
:
None
):
super
(
AppendCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
=
lambda
a
:
None
)
super
(
AppendCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
=
lambda
a
:
None
)
def
execute
(
self
):
if
not
super
(
AppendCommand
,
self
).
execute
():
...
...
@@ -48,4 +49,6 @@ class AppendCommand(Command):
return
"""Synopsis: append <number> <text>"""
def
help
(
self
):
return
"""Adds the given <text> to the end of the todo indicated by <number>."""
return
"""
\
Adds the given <text> to the end of the todo indicated by <number>.
"""
topydo/lib/ArchiveCommand.py
View file @
43c6beee
topydo/lib/Command.py
View file @
43c6beee
...
...
@@ -73,9 +73,9 @@ class Command(object):
def
getopt
(
self
,
p_flags
,
p_long
=
[]):
try
:
result
=
getopt
.
getopt
(
self
.
args
,
p_flags
,
p_long
)
except
getopt
.
GetoptError
as
e
:
self
.
error
(
str
(
e
))
result
=
([],
self
.
args
)
except
getopt
.
GetoptError
as
go
e
:
self
.
error
(
str
(
go
e
))
result
=
([],
self
.
args
)
return
result
...
...
topydo/lib/Config.py
View file @
43c6beee
...
...
@@ -146,8 +146,8 @@ def config(p_path=None):
if
not
config
.
instance
or
p_path
!=
None
:
try
:
config
.
instance
=
_Config
(
p_path
)
except
ConfigParser
.
ParsingError
as
e
:
raise
ConfigError
(
str
(
e
))
except
ConfigParser
.
ParsingError
as
perr
:
raise
ConfigError
(
str
(
perr
))
return
config
.
instance
...
...
topydo/lib/DCommand.py
View file @
43c6beee
...
...
@@ -30,7 +30,8 @@ class DCommand(Command):
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
lambda
a
:
None
):
super
(
DCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
DCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
self
.
force
=
False
...
...
@@ -63,7 +64,9 @@ class DCommand(Command):
self
.
args
=
args
def
_uncompleted_children
(
self
,
p_todo
):
return
sorted
([
t
for
t
in
self
.
todolist
.
children
(
p_todo
)
if
not
t
.
is_completed
()])
return
sorted
(
[
t
for
t
in
self
.
todolist
.
children
(
p_todo
)
if
not
t
.
is_completed
()]
)
def
_print_list
(
self
,
p_todos
,
p_print_numbers
=
True
):
filters
=
[]
...
...
@@ -109,10 +112,13 @@ class DCommand(Command):
Since these todos pop up at the end of the list, we cut off the list
just before that point.
"""
return
[
todo
for
todo
in
self
.
todolist
.
todos
()[:
self
.
length
]
if
not
self
.
_uncompleted_children
(
todo
)
and
todo
.
is_active
()]
return
[
todo
for
todo
in
self
.
todolist
.
todos
()[:
self
.
length
]
if
not
self
.
_uncompleted_children
(
todo
)
and
todo
.
is_active
()]
def
condition
(
self
):
""" An additional condition whether execute_specific should be executed. """
"""
An additional condition whether execute_specific should be executed.
"""
return
True
def
condition_failed_text
(
self
):
...
...
topydo/lib/DeleteCommand.py
View file @
43c6beee
...
...
@@ -22,7 +22,8 @@ class DeleteCommand(DCommand):
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
lambda
a
:
None
):
super
(
DeleteCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
DeleteCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
def
prompt_text
(
self
):
return
"Also remove subtasks? [y/N] "
...
...
topydo/lib/DepCommand.py
View file @
43c6beee
...
...
@@ -26,7 +26,8 @@ class DepCommand(Command):
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
lambda
a
:
None
):
super
(
DepCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
DepCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
try
:
self
.
subsubcommand
=
self
.
argument
(
0
)
...
...
@@ -130,7 +131,10 @@ class DepCommand(Command):
dep clean"""
def
help
(
self
):
return
"""* add: Adds a dependency. Using 1 before 2 creates a dependency from todo item 2 to 1.
* rm (alias: del): Removes a dependency.
* ls: Lists all dependencies to or from a certain todo.
* clean (alias: gc): Removes redundant id or p tags."""
return
"""
\
* add : Adds a dependency. Using 1 before 2 creates a dependency
from todo item 2 to 1.
* rm (alias: del) : Removes a dependency.
* ls : Lists all dependencies to or from a certain todo.
* clean (alias: gc): Removes redundant id or p tags.
"""
topydo/lib/DepriCommand.py
View file @
43c6beee
...
...
@@ -23,7 +23,8 @@ class DepriCommand(Command):
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
lambda
a
:
None
):
super
(
DepriCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
DepriCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
def
execute
(
self
):
if
not
super
(
DepriCommand
,
self
).
execute
():
...
...
topydo/lib/DoCommand.py
View file @
43c6beee
...
...
@@ -30,7 +30,8 @@ class DoCommand(DCommand):
self
.
strict_recurrence
=
False
self
.
completion_date
=
date
.
today
()
super
(
DoCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
DoCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
def
get_flags
(
self
):
""" Additional flags. """
...
...
@@ -59,7 +60,9 @@ class DoCommand(DCommand):
return
"Completed: "
def
condition
(
self
):
""" An additional condition whether execute_specific should be executed. """
"""
An additional condition whether execute_specific should be executed.
"""
return
not
self
.
todo
.
is_completed
()
def
condition_failed_text
(
self
):
...
...
topydo/lib/Filter.py
View file @
43c6beee
...
...
@@ -60,6 +60,8 @@ class GrepFilter(Filter):
""" Matches when the todo text contains a text. """
def
__init__
(
self
,
p_expression
,
p_case_sensitive
=
None
):
super
(
GrepFilter
,
self
).
__init__
()
self
.
expression
=
p_expression
if
p_case_sensitive
!=
None
:
...
...
@@ -107,6 +109,7 @@ class DependencyFilter(Filter):
Pass on a TodoList instance such that the dependencies can be
looked up.
"""
super
(
DependencyFilter
,
self
).
__init__
()
self
.
todolist
=
p_todolist
def
match
(
self
,
p_todo
):
...
...
@@ -128,6 +131,7 @@ class InstanceFilter(Filter):
This is handy for constructing a view given a plain list of Todo items.
"""
super
(
InstanceFilter
,
self
).
__init__
()
self
.
todos
=
p_todos
def
match
(
self
,
p_todo
):
...
...
@@ -142,6 +146,7 @@ class InstanceFilter(Filter):
class
LimitFilter
(
Filter
):
def
__init__
(
self
,
p_limit
):
super
(
LimitFilter
,
self
).
__init__
()
self
.
limit
=
p_limit
def
filter
(
self
,
p_todos
):
...
...
@@ -151,6 +156,7 @@ ORDINAL_TAG_MATCH = r"(?P<key>[^:]*):(?P<operator><=?|=|>=?|!)?(?P<value>\S*)"
class OrdinalTagFilter(Filter):
def __init__(self, p_expression):
super(OrdinalTagFilter, self).__init__()
match = re.match(ORDINAL_TAG_MATCH, p_expression)
if match:
self.key = match.group('key')
...
...
topydo/lib/ListCommand.py
View file @
43c6beee
...
...
@@ -27,7 +27,8 @@ class ListCommand(Command.Command):
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
lambda
a
:
None
):
super
(
ListCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
ListCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
self
.
sort_expression
=
config
().
sort_string
()
self
.
show_all
=
False
...
...
@@ -35,11 +36,11 @@ class ListCommand(Command.Command):
def
_process_flags
(
self
):
opts
,
args
=
self
.
getopt
(
's:x'
)
for
o
,
a
in
opts
:
if
o
==
'-x'
:
for
o
pt
,
value
in
opts
:
if
o
pt
==
'-x'
:
self
.
show_all
=
True
elif
o
==
'-s'
:
self
.
sort_expression
=
a
elif
o
pt
==
'-s'
:
self
.
sort_expression
=
value
self
.
args
=
args
...
...
@@ -53,7 +54,8 @@ class ListCommand(Command.Command):
argfilter
=
Filter
.
OrdinalTagFilter
(
arg
)
elif
len
(
arg
)
>
1
and
arg
[
0
]
==
'-'
:
# when a word starts with -, exclude it
argfilter
=
Filter
.
NegationFilter
(
Filter
.
GrepFilter
(
arg
[
1
:]))
argfilter
=
Filter
.
GrepFilter
(
arg
[
1
:])
argfilter
=
Filter
.
NegationFilter
(
argfilter
)
else
:
argfilter
=
Filter
.
GrepFilter
(
arg
)
...
...
@@ -88,7 +90,8 @@ class ListCommand(Command.Command):
return
"""Synopsis: ls [-x] [-s <sort_expression>] [expression]"""
def
help
(
self
):
return
"""Lists all relevant todos. A todo is relevant when:
return
"""
\
Lists all relevant todos. A todo is relevant when:
* has not been completed yet;
* the start date (if present) has passed;
...
...
@@ -98,4 +101,5 @@ When an expression is given, only the todos matching that expression are shown.
-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 or relevance).
"""
topydo/lib/ListContextCommand.py
View file @
43c6beee
...
...
@@ -21,7 +21,8 @@ class ListContextCommand(Command.Command):
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
lambda
a
:
None
):
super
(
ListContextCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
ListContextCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
def
execute
(
self
):
if
not
super
(
ListContextCommand
,
self
).
execute
():
...
...
topydo/lib/ListProjectCommand.py
View file @
43c6beee
...
...
@@ -21,7 +21,8 @@ class ListProjectCommand(Command.Command):
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
lambda
a
:
None
):
super
(
ListProjectCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
ListProjectCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
def
execute
(
self
):
if
not
super
(
ListProjectCommand
,
self
).
execute
():
...
...
topydo/lib/PostponeCommand.py
View file @
43c6beee
...
...
@@ -28,15 +28,16 @@ class PostponeCommand(Command):
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
lambda
a
:
None
):
super
(
PostponeCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
PostponeCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
self
.
move_start_date
=
False
def
_process_flags
(
self
):
opts
,
args
=
self
.
getopt
(
's'
)
for
o
,
a
in
opts
:
if
o
==
'-s'
:
for
o
pt
,
_
in
opts
:
if
o
pt
==
'-s'
:
self
.
move_start_date
=
True
self
.
args
=
args
...
...
@@ -86,7 +87,8 @@ class PostponeCommand(Command):
return
"Synopsis: postpone [-s] <NUMBER> <PATTERN>"
def
help
(
self
):
return
"""Postpone a todo item with the given number and the given pattern.
return
"""
\
Postpone a todo item with the given number and the given pattern.
Postponing is done by adjusting the due date of the todo, and if the -s flag is
given, the start date accordingly.
...
...
@@ -94,4 +96,5 @@ given, the start date accordingly.
The pattern is a relative date, written in the format <COUNT><PERIOD> where
count is a number and <PERIOD> is either 'd', 'w', 'm' or 'y', which stands for
days, weeks, months and years respectively. Example: 'postpone 1 1w' postpones
todo number 1 for 1 week."""
todo number 1 for 1 week.
"""
topydo/lib/PrettyPrinter.py
View file @
43c6beee
...
...
@@ -46,7 +46,9 @@ def pp_color(p_todo_str, p_todo):
p_todo_str
=
'%s%s%s'
%
(
color
,
p_todo_str
,
NEUTRAL_COLOR
)
if
config
().
highlight_projects_contexts
():
p_todo_str
=
re
.
sub
(
r'\
B(
\+|@)(\
S*
\w)'
,
PROJECT_COLOR
+
r'\
g<
0>'
+
color
,
\
p_todo_str
=
re
.
sub
(
r'\
B(
\+|@)(\
S*
\w)'
,
PROJECT_COLOR
+
r'\
g<
0>'
+
color
,
p_todo_str
)
p_todo_str
+=
NEUTRAL_COLOR
...
...
topydo/lib/PriorityCommand.py
View file @
43c6beee
...
...
@@ -24,7 +24,8 @@ class PriorityCommand(Command):
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
lambda
a
:
None
):
super
(
PriorityCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
PriorityCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
def
execute
(
self
):
if
not
super
(
PriorityCommand
,
self
).
execute
():
...
...
@@ -61,4 +62,6 @@ class PriorityCommand(Command):
return
"""Synopsis: pri <NUMBER> <PRIORITY>"""
def
help
(
self
):
return
"""Sets the priority of todo the given number to the given priority."""
return
"""
\
Sets the priority of todo the given number to the given priority.
"""
topydo/lib/RelativeDate.py
View file @
43c6beee
...
...
@@ -81,7 +81,18 @@ def relative_date_to_date(p_date, p_offset=date.today()):
p_date
=
p_date
.
lower
()
relative
=
re
.
match
(
'(?P<length>[0-9]+)(?P<period>[dwmy])$'
,
p_date
,
re
.
I
)
weekday
=
re
.
match
(
'mo(n(day)?)?$|tu(e(sday)?)?$|we(d(nesday)?)?$|th(u(rsday)?)?$|fr(i(day)?)?$|sa(t(urday)?)?$|su(n(day)?)?$'
,
p_date
)
monday
=
'mo(n(day)?)?$'
tuesday
=
'tu(e(sday)?)?$'
wednesday
=
'we(d(nesday)?)?$'
thursday
=
'th(u(rsday)?)?$'
friday
=
'fr(i(day)?)?$'
saturday
=
'sa(t(urday)?)?$'
sunday
=
'su(n(day)?)?$'
weekday
=
re
.
match
(
'|'
.
join
(
[
monday
,
tuesday
,
wednesday
,
thursday
,
friday
,
saturday
,
sunday
]),
p_date
)
if
relative
:
length
=
relative
.
group
(
'length'
)
...
...
topydo/lib/SortCommand.py
View file @
43c6beee
...
...
@@ -23,7 +23,8 @@ class SortCommand(Command):
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
lambda
a
:
None
):
super
(
SortCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
SortCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
def
execute
(
self
):
if
not
super
(
SortCommand
,
self
).
execute
():
...
...
@@ -46,8 +47,9 @@ class SortCommand(Command):
return
"""Synopsis: sort [expression]"""
def
help
(
self
):
return
"""Sorts the file according to the expression. If no expression is given,
the expression in the configuration is used.
return
"""
\
Sorts the file according to the expression. If no expression is given, the
expression in the configuration is used.
The following sort properties are supported:
...
...
topydo/lib/Sorter.py
View file @
43c6beee
...
...
@@ -45,9 +45,9 @@ def get_field_function(p_field):
result
=
(
lambda
a
:
a
.
completion_date
()
if
a
.
completion_date
()
\
else
date
.
max
)
elif
p_field
==
'importance'
:
result
=
lambda
a
:
importance
(
a
)
result
=
importance
elif
p_field
==
'importance-avg'
or
p_field
==
'importance-average'
:
result
=
lambda
a
:
average_importance
(
a
)
result
=
average_importance
elif
p_field
==
'text'
:
result
=
lambda
a
:
a
.
text
()
else
:
...
...
topydo/lib/TagCommand.py
View file @
43c6beee
...
...
@@ -23,7 +23,8 @@ class TagCommand(Command):
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
lambda
a
:
None
):
super
(
TagCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
TagCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
self
.
force
=
False
self
.
force_add
=
False
...
...
@@ -31,10 +32,11 @@ class TagCommand(Command):
self
.
tag
=
None
self
.
value
=
None
self
.
values
=
[]
self
.
current_values
=
[]
def
_process_flags
(
self
):
flags
,
args
=
self
.
getopt
(
"af"
)
for
flag
,
value
in
flags
:
for
flag
,
_
in
flags
:
if
flag
==
"-a"
:
self
.
force_add
=
True
elif
flag
==
"-f"
:
...
...
@@ -70,7 +72,8 @@ class TagCommand(Command):
for
i
,
value
in
enumerate
(
self
.
current_values
):
self
.
out
(
"%2d. %s"
%
(
i
+
1
,
value
))
answer
=
self
.
prompt
(
'Which value to remove? Enter number or "all": '
)
answer
=
self
.
prompt
(
'Which value to remove? Enter number or "all": '
)
if
answer
!=
"all"
:
try
:
...
...
@@ -118,9 +121,12 @@ class TagCommand(Command):
return
"""Synopsis: tag [-a] [-f] <NUMBER> <tag> [<value>]"""
def
help
(
self
):
return
"""Sets the given tag to the given todo number with the given value. If
the value is omitted, the tag is removed from the todo item.
-a : Do not change the current value of the tag if it exists, but add a new value.
-f : Force setting/removing all values of the tag. Prevents interaction with the user.
"""
return
"""
\
Sets the given tag to the given todo number with the given value. If the value
is omitted, the tag is removed from the todo item.
-a : Do not change the current value of the tag if it exists, but add a new
value.
-f : Force setting/removing all values of the tag. Prevents interaction with the
user.
"""
topydo/lib/TodoList.py
View file @
43c6beee
...
...
@@ -145,7 +145,8 @@ class TodoList(TodoListBase.TodoListBase):
Returns a list of parent todos that (in)directly depend on the
given todo.
"""
parents
=
self
.
_depgraph
.
incoming_neighbors
(
hash
(
p_todo
),
not
p_only_direct
)
parents
=
self
.
_depgraph
.
incoming_neighbors
(
hash
(
p_todo
),
not
p_only_direct
)
return
[
self
.
_tododict
[
parent
]
for
parent
in
parents
]
def
children
(
self
,
p_todo
,
p_only_direct
=
False
):
...
...
@@ -167,7 +168,9 @@ class TodoList(TodoListBase.TodoListBase):
"""
def
clean_by_tag
(
tag_name
):
""" Generic function to handle 'p' and 'id' tags. """
for
todo
in
[
todo
for
todo
in
self
.
_todos
if
todo
.
has_tag
(
tag_name
)]:
for
todo
in
[
todo
for
todo
in
self
.
_todos
if
todo
.
has_tag
(
tag_name
)]:
value
=
todo
.
tag_value
(
tag_name
)
if
not
self
.
_depgraph
.
has_edge_id
(
value
):
todo
.
remove_tag
(
tag_name
,
value
)
...
...
topydo/lib/TodoListBase.py
View file @
43c6beee
...
...
@@ -185,7 +185,8 @@ class TodoListBase(object):
A filter for the pretty printer to append the todo number to the
printed todo.
"""
return lambda p_todo_str, p_todo: "%3d %s" % (self.number(p_todo), p_todo_str)
return lambda p_todo_str, p_todo:
\
"%3d %s" % (self.number(p_todo), p_todo_str)
def __str__(self):
return '
\
n
'.join(pretty_print_list(self._todos))
...
...
topydo/lib/TodoParser.py
View file @
43c6beee
...
...
@@ -23,12 +23,19 @@ import re
import
Utils
_date_match
=
r'\
d{
4}-\
d{
2}-\
d{
2}'
_completed_head_match
=
re
.
compile
(
r'x ((?P<completionDate>'
+
_date_match
+
') )'
+
'((?P<creationDate>'
+
_date_match
+
') )?(?P<rest>.*)'
)
_normal_head_match
=
re
.
compile
(
r'(\
((?P<p
riority>[A-Z])\
) )?
' + '
((
?
P
<
creationDate
>
' + _date_match + '
)
)
?
(
?
P
<
rest
>
.
*
)
')
_tag_match = re.compile('
(
?
P
<
key
>
[
^
:]
*
):(
?
P
<
value
>
.
*
)
')
_project_match = re.compile(r'
\
+
(
\
S
*
\
w
)
')
_context_match = re.compile(r'
@
(
\
S
*
\
w
)
')
_DATE_MATCH
=
r'\
d{
4}-\
d{
2}-\
d{
2}'
_COMPLETED_HEAD_MATCH
=
re
.
compile
(
r'x ((?P<completionDate>'
+
_DATE_MATCH
+
') )'
+
'((?P<creationDate>'
+
_DATE_MATCH
+
') )?(?P<rest>.*)'
)
_NORMAL_HEAD_MATCH
=
re
.
compile
(
r'(\
((?P<p
riority>[A-Z])\
) )?
' + '
((
?
P
<
creationDate
>
' + _DATE_MATCH +
'
)
)
?
(
?
P
<
rest
>
.
*
)
')
_TAG_MATCH = re.compile('
(
?
P
<
key
>
[
^
:]
*
):(
?
P
<
value
>
.
*
)
')
_PROJECT_MATCH = re.compile(r'
\
+
(
\
S
*
\
w
)
')
_CONTEXT_MATCH = re.compile(r'
@
(
\
S
*
\
w
)
')
def parse_line(p_string):
"""
...
...
@@ -52,8 +59,8 @@ def parse_line(p_string):
'
tags
': []
}
completed_head = _
completed_head_match
.match(p_string)
normal_head = _
normal_head_match
.match(p_string)
completed_head = _
COMPLETED_HEAD_MATCH
.match(p_string)
normal_head = _
NORMAL_HEAD_MATCH
.match(p_string)
rest = p_string
...
...
@@ -76,15 +83,15 @@ def parse_line(p_string):
rest = normal_head.group('
rest
')
for word in rest.split():
project = _
project_match
.match(word)
project = _
PROJECT_MATCH
.match(word)
if project:
result['
projects
'].append(project.group(1))
context = _
context_match
.match(word)
context = _
CONTEXT_MATCH
.match(word)
if context:
result['
contexts
'].append(context.group(1))
tag = _
tag_match
.match(word)
tag = _
TAG_MATCH
.match(word)
if tag:
result['
tags
'].append((tag.group('
key
'), tag.group('
value
')))
continue
...
...
topydo/lib/View.py
View file @
43c6beee
...
...
@@ -44,7 +44,7 @@ class View(object):
def
pretty_print
(
self
,
p_pp_filters
=
[]):
""" Pretty prints the view. """
pp_filters
=
[
self
.
_todolist
.
pp_number
(),
pp_color
]
+
p_pp_filters
;
pp_filters
=
[
self
.
_todolist
.
pp_number
(),
pp_color
]
+
p_pp_filters
return
'
\
n
'
.
join
(
pretty_print_list
(
self
.
_viewdata
,
pp_filters
))
def
__str__
(
self
):
...
...
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