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):
...
@@ -30,8 +30,10 @@ class AddCommand(Command.Command):
p_out
=
lambda
a
:
None
,
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
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
.
text
=
' '
.
join
(
p_args
)
self
.
todo
=
None
def
_preprocess_input_todo
(
self
):
def
_preprocess_input_todo
(
self
):
"""
"""
...
@@ -102,7 +104,8 @@ class AddCommand(Command.Command):
...
@@ -102,7 +104,8 @@ class AddCommand(Command.Command):
return
"""Synopsis: add <text>"""
return
"""Synopsis: add <text>"""
def
help
(
self
):
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:
<text> may contain:
...
...
topydo/lib/AppendCommand.py
View file @
43c6beee
...
@@ -23,7 +23,8 @@ class AppendCommand(Command):
...
@@ -23,7 +23,8 @@ class AppendCommand(Command):
p_out
=
lambda
a
:
None
,
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
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
):
def
execute
(
self
):
if
not
super
(
AppendCommand
,
self
).
execute
():
if
not
super
(
AppendCommand
,
self
).
execute
():
...
@@ -48,4 +49,6 @@ class AppendCommand(Command):
...
@@ -48,4 +49,6 @@ class AppendCommand(Command):
return
"""Synopsis: append <number> <text>"""
return
"""Synopsis: append <number> <text>"""
def
help
(
self
):
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):
...
@@ -73,9 +73,9 @@ class Command(object):
def
getopt
(
self
,
p_flags
,
p_long
=
[]):
def
getopt
(
self
,
p_flags
,
p_long
=
[]):
try
:
try
:
result
=
getopt
.
getopt
(
self
.
args
,
p_flags
,
p_long
)
result
=
getopt
.
getopt
(
self
.
args
,
p_flags
,
p_long
)
except
getopt
.
GetoptError
as
e
:
except
getopt
.
GetoptError
as
go
e
:
self
.
error
(
str
(
e
))
self
.
error
(
str
(
go
e
))
result
=
([],
self
.
args
)
result
=
([],
self
.
args
)
return
result
return
result
...
...
topydo/lib/Config.py
View file @
43c6beee
...
@@ -146,8 +146,8 @@ def config(p_path=None):
...
@@ -146,8 +146,8 @@ def config(p_path=None):
if
not
config
.
instance
or
p_path
!=
None
:
if
not
config
.
instance
or
p_path
!=
None
:
try
:
try
:
config
.
instance
=
_Config
(
p_path
)
config
.
instance
=
_Config
(
p_path
)
except
ConfigParser
.
ParsingError
as
e
:
except
ConfigParser
.
ParsingError
as
perr
:
raise
ConfigError
(
str
(
e
))
raise
ConfigError
(
str
(
perr
))
return
config
.
instance
return
config
.
instance
...
...
topydo/lib/DCommand.py
View file @
43c6beee
...
@@ -30,7 +30,8 @@ class DCommand(Command):
...
@@ -30,7 +30,8 @@ class DCommand(Command):
p_out
=
lambda
a
:
None
,
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
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
self
.
force
=
False
...
@@ -63,7 +64,9 @@ class DCommand(Command):
...
@@ -63,7 +64,9 @@ class DCommand(Command):
self
.
args
=
args
self
.
args
=
args
def
_uncompleted_children
(
self
,
p_todo
):
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
):
def
_print_list
(
self
,
p_todos
,
p_print_numbers
=
True
):
filters
=
[]
filters
=
[]
...
@@ -109,10 +112,13 @@ class DCommand(Command):
...
@@ -109,10 +112,13 @@ class DCommand(Command):
Since these todos pop up at the end of the list, we cut off the list
Since these todos pop up at the end of the list, we cut off the list
just before that point.
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
):
def
condition
(
self
):
""" An additional condition whether execute_specific should be executed. """
"""
An additional condition whether execute_specific should be executed.
"""
return
True
return
True
def
condition_failed_text
(
self
):
def
condition_failed_text
(
self
):
...
...
topydo/lib/DeleteCommand.py
View file @
43c6beee
...
@@ -22,7 +22,8 @@ class DeleteCommand(DCommand):
...
@@ -22,7 +22,8 @@ class DeleteCommand(DCommand):
p_out
=
lambda
a
:
None
,
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
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
):
def
prompt_text
(
self
):
return
"Also remove subtasks? [y/N] "
return
"Also remove subtasks? [y/N] "
...
...
topydo/lib/DepCommand.py
View file @
43c6beee
...
@@ -26,7 +26,8 @@ class DepCommand(Command):
...
@@ -26,7 +26,8 @@ class DepCommand(Command):
p_out
=
lambda
a
:
None
,
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
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
:
try
:
self
.
subsubcommand
=
self
.
argument
(
0
)
self
.
subsubcommand
=
self
.
argument
(
0
)
...
@@ -130,7 +131,10 @@ class DepCommand(Command):
...
@@ -130,7 +131,10 @@ class DepCommand(Command):
dep clean"""
dep clean"""
def
help
(
self
):
def
help
(
self
):
return
"""* add: Adds a dependency. Using 1 before 2 creates a dependency from todo item 2 to 1.
return
"""
\
* rm (alias: del): Removes a dependency.
* add : Adds a dependency. Using 1 before 2 creates a dependency
* ls: Lists all dependencies to or from a certain todo.
from todo item 2 to 1.
* clean (alias: gc): Removes redundant id or p tags."""
* 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):
...
@@ -23,7 +23,8 @@ class DepriCommand(Command):
p_out
=
lambda
a
:
None
,
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
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
):
def
execute
(
self
):
if
not
super
(
DepriCommand
,
self
).
execute
():
if
not
super
(
DepriCommand
,
self
).
execute
():
...
...
topydo/lib/DoCommand.py
View file @
43c6beee
...
@@ -30,7 +30,8 @@ class DoCommand(DCommand):
...
@@ -30,7 +30,8 @@ class DoCommand(DCommand):
self
.
strict_recurrence
=
False
self
.
strict_recurrence
=
False
self
.
completion_date
=
date
.
today
()
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
):
def
get_flags
(
self
):
""" Additional flags. """
""" Additional flags. """
...
@@ -59,7 +60,9 @@ class DoCommand(DCommand):
...
@@ -59,7 +60,9 @@ class DoCommand(DCommand):
return
"Completed: "
return
"Completed: "
def
condition
(
self
):
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
()
return
not
self
.
todo
.
is_completed
()
def
condition_failed_text
(
self
):
def
condition_failed_text
(
self
):
...
...
topydo/lib/Filter.py
View file @
43c6beee
...
@@ -60,6 +60,8 @@ class GrepFilter(Filter):
...
@@ -60,6 +60,8 @@ class GrepFilter(Filter):
""" Matches when the todo text contains a text. """
""" Matches when the todo text contains a text. """
def
__init__
(
self
,
p_expression
,
p_case_sensitive
=
None
):
def
__init__
(
self
,
p_expression
,
p_case_sensitive
=
None
):
super
(
GrepFilter
,
self
).
__init__
()
self
.
expression
=
p_expression
self
.
expression
=
p_expression
if
p_case_sensitive
!=
None
:
if
p_case_sensitive
!=
None
:
...
@@ -107,6 +109,7 @@ class DependencyFilter(Filter):
...
@@ -107,6 +109,7 @@ class DependencyFilter(Filter):
Pass on a TodoList instance such that the dependencies can be
Pass on a TodoList instance such that the dependencies can be
looked up.
looked up.
"""
"""
super
(
DependencyFilter
,
self
).
__init__
()
self
.
todolist
=
p_todolist
self
.
todolist
=
p_todolist
def
match
(
self
,
p_todo
):
def
match
(
self
,
p_todo
):
...
@@ -128,6 +131,7 @@ class InstanceFilter(Filter):
...
@@ -128,6 +131,7 @@ class InstanceFilter(Filter):
This is handy for constructing a view given a plain list of Todo items.
This is handy for constructing a view given a plain list of Todo items.
"""
"""
super
(
InstanceFilter
,
self
).
__init__
()
self
.
todos
=
p_todos
self
.
todos
=
p_todos
def
match
(
self
,
p_todo
):
def
match
(
self
,
p_todo
):
...
@@ -142,6 +146,7 @@ class InstanceFilter(Filter):
...
@@ -142,6 +146,7 @@ class InstanceFilter(Filter):
class
LimitFilter
(
Filter
):
class
LimitFilter
(
Filter
):
def
__init__
(
self
,
p_limit
):
def
__init__
(
self
,
p_limit
):
super
(
LimitFilter
,
self
).
__init__
()
self
.
limit
=
p_limit
self
.
limit
=
p_limit
def
filter
(
self
,
p_todos
):
def
filter
(
self
,
p_todos
):
...
@@ -151,6 +156,7 @@ ORDINAL_TAG_MATCH = r"(?P<key>[^:]*):(?P<operator><=?|=|>=?|!)?(?P<value>\S*)"
...
@@ -151,6 +156,7 @@ ORDINAL_TAG_MATCH = r"(?P<key>[^:]*):(?P<operator><=?|=|>=?|!)?(?P<value>\S*)"
class OrdinalTagFilter(Filter):
class OrdinalTagFilter(Filter):
def __init__(self, p_expression):
def __init__(self, p_expression):
super(OrdinalTagFilter, self).__init__()
match = re.match(ORDINAL_TAG_MATCH, p_expression)
match = re.match(ORDINAL_TAG_MATCH, p_expression)
if match:
if match:
self.key = match.group('key')
self.key = match.group('key')
...
...
topydo/lib/ListCommand.py
View file @
43c6beee
...
@@ -27,7 +27,8 @@ class ListCommand(Command.Command):
...
@@ -27,7 +27,8 @@ class ListCommand(Command.Command):
p_out
=
lambda
a
:
None
,
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
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
.
sort_expression
=
config
().
sort_string
()
self
.
show_all
=
False
self
.
show_all
=
False
...
@@ -35,11 +36,11 @@ class ListCommand(Command.Command):
...
@@ -35,11 +36,11 @@ class ListCommand(Command.Command):
def
_process_flags
(
self
):
def
_process_flags
(
self
):
opts
,
args
=
self
.
getopt
(
's:x'
)
opts
,
args
=
self
.
getopt
(
's:x'
)
for
o
,
a
in
opts
:
for
o
pt
,
value
in
opts
:
if
o
==
'-x'
:
if
o
pt
==
'-x'
:
self
.
show_all
=
True
self
.
show_all
=
True
elif
o
==
'-s'
:
elif
o
pt
==
'-s'
:
self
.
sort_expression
=
a
self
.
sort_expression
=
value
self
.
args
=
args
self
.
args
=
args
...
@@ -53,7 +54,8 @@ class ListCommand(Command.Command):
...
@@ -53,7 +54,8 @@ class ListCommand(Command.Command):
argfilter
=
Filter
.
OrdinalTagFilter
(
arg
)
argfilter
=
Filter
.
OrdinalTagFilter
(
arg
)
elif
len
(
arg
)
>
1
and
arg
[
0
]
==
'-'
:
elif
len
(
arg
)
>
1
and
arg
[
0
]
==
'-'
:
# when a word starts with -, exclude it
# when a word starts with -, exclude it
argfilter
=
Filter
.
NegationFilter
(
Filter
.
GrepFilter
(
arg
[
1
:]))
argfilter
=
Filter
.
GrepFilter
(
arg
[
1
:])
argfilter
=
Filter
.
NegationFilter
(
argfilter
)
else
:
else
:
argfilter
=
Filter
.
GrepFilter
(
arg
)
argfilter
=
Filter
.
GrepFilter
(
arg
)
...
@@ -88,7 +90,8 @@ class ListCommand(Command.Command):
...
@@ -88,7 +90,8 @@ class ListCommand(Command.Command):
return
"""Synopsis: ls [-x] [-s <sort_expression>] [expression]"""
return
"""Synopsis: ls [-x] [-s <sort_expression>] [expression]"""
def
help
(
self
):
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;
* has not been completed yet;
* the start date (if present) has passed;
* the start date (if present) has passed;
...
@@ -98,4 +101,5 @@ When an expression is given, only the todos matching that expression are shown.
...
@@ -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
-s : Sort the list according to a sort expression. Defaults to the expression
in the configuration.
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):
...
@@ -21,7 +21,8 @@ class ListContextCommand(Command.Command):
p_out
=
lambda
a
:
None
,
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
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
):
def
execute
(
self
):
if
not
super
(
ListContextCommand
,
self
).
execute
():
if
not
super
(
ListContextCommand
,
self
).
execute
():
...
...
topydo/lib/ListProjectCommand.py
View file @
43c6beee
...
@@ -21,7 +21,8 @@ class ListProjectCommand(Command.Command):
...
@@ -21,7 +21,8 @@ class ListProjectCommand(Command.Command):
p_out
=
lambda
a
:
None
,
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
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
):
def
execute
(
self
):
if
not
super
(
ListProjectCommand
,
self
).
execute
():
if
not
super
(
ListProjectCommand
,
self
).
execute
():
...
...
topydo/lib/PostponeCommand.py
View file @
43c6beee
...
@@ -28,15 +28,16 @@ class PostponeCommand(Command):
...
@@ -28,15 +28,16 @@ class PostponeCommand(Command):
p_out
=
lambda
a
:
None
,
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
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
self
.
move_start_date
=
False
def
_process_flags
(
self
):
def
_process_flags
(
self
):
opts
,
args
=
self
.
getopt
(
's'
)
opts
,
args
=
self
.
getopt
(
's'
)
for
o
,
a
in
opts
:
for
o
pt
,
_
in
opts
:
if
o
==
'-s'
:
if
o
pt
==
'-s'
:
self
.
move_start_date
=
True
self
.
move_start_date
=
True
self
.
args
=
args
self
.
args
=
args
...
@@ -86,7 +87,8 @@ class PostponeCommand(Command):
...
@@ -86,7 +87,8 @@ class PostponeCommand(Command):
return
"Synopsis: postpone [-s] <NUMBER> <PATTERN>"
return
"Synopsis: postpone [-s] <NUMBER> <PATTERN>"
def
help
(
self
):
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
Postponing is done by adjusting the due date of the todo, and if the -s flag is
given, the start date accordingly.
given, the start date accordingly.
...
@@ -94,4 +96,5 @@ 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
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
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
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):
...
@@ -46,7 +46,9 @@ def pp_color(p_todo_str, p_todo):
p_todo_str
=
'%s%s%s'
%
(
color
,
p_todo_str
,
NEUTRAL_COLOR
)
p_todo_str
=
'%s%s%s'
%
(
color
,
p_todo_str
,
NEUTRAL_COLOR
)
if
config
().
highlight_projects_contexts
():
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
)
p_todo_str
+=
NEUTRAL_COLOR
p_todo_str
+=
NEUTRAL_COLOR
...
...
topydo/lib/PriorityCommand.py
View file @
43c6beee
...
@@ -24,7 +24,8 @@ class PriorityCommand(Command):
...
@@ -24,7 +24,8 @@ class PriorityCommand(Command):
p_out
=
lambda
a
:
None
,
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
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
):
def
execute
(
self
):
if
not
super
(
PriorityCommand
,
self
).
execute
():
if
not
super
(
PriorityCommand
,
self
).
execute
():
...
@@ -61,4 +62,6 @@ class PriorityCommand(Command):
...
@@ -61,4 +62,6 @@ class PriorityCommand(Command):
return
"""Synopsis: pri <NUMBER> <PRIORITY>"""
return
"""Synopsis: pri <NUMBER> <PRIORITY>"""
def
help
(
self
):
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()):
...
@@ -81,7 +81,18 @@ def relative_date_to_date(p_date, p_offset=date.today()):
p_date
=
p_date
.
lower
()
p_date
=
p_date
.
lower
()
relative
=
re
.
match
(
'(?P<length>[0-9]+)(?P<period>[dwmy])$'
,
p_date
,
re
.
I
)
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
:
if
relative
:
length
=
relative
.
group
(
'length'
)
length
=
relative
.
group
(
'length'
)
...
...
topydo/lib/SortCommand.py
View file @
43c6beee
...
@@ -23,7 +23,8 @@ class SortCommand(Command):
...
@@ -23,7 +23,8 @@ class SortCommand(Command):
p_out
=
lambda
a
:
None
,
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
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
):
def
execute
(
self
):
if
not
super
(
SortCommand
,
self
).
execute
():
if
not
super
(
SortCommand
,
self
).
execute
():
...
@@ -46,8 +47,9 @@ class SortCommand(Command):
...
@@ -46,8 +47,9 @@ class SortCommand(Command):
return
"""Synopsis: sort [expression]"""
return
"""Synopsis: sort [expression]"""
def
help
(
self
):
def
help
(
self
):
return
"""Sorts the file according to the expression. If no expression is given,
return
"""
\
the expression in the configuration is used.
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:
The following sort properties are supported:
...
...
topydo/lib/Sorter.py
View file @
43c6beee
...
@@ -45,9 +45,9 @@ def get_field_function(p_field):
...
@@ -45,9 +45,9 @@ def get_field_function(p_field):
result
=
(
lambda
a
:
a
.
completion_date
()
if
a
.
completion_date
()
\
result
=
(
lambda
a
:
a
.
completion_date
()
if
a
.
completion_date
()
\
else
date
.
max
)
else
date
.
max
)
elif
p_field
==
'importance'
:
elif
p_field
==
'importance'
:
result
=
lambda
a
:
importance
(
a
)
result
=
importance
elif
p_field
==
'importance-avg'
or
p_field
==
'importance-average'
:
elif
p_field
==
'importance-avg'
or
p_field
==
'importance-average'
:
result
=
lambda
a
:
average_importance
(
a
)
result
=
average_importance
elif
p_field
==
'text'
:
elif
p_field
==
'text'
:
result
=
lambda
a
:
a
.
text
()
result
=
lambda
a
:
a
.
text
()
else
:
else
:
...
...
topydo/lib/TagCommand.py
View file @
43c6beee
...
@@ -23,7 +23,8 @@ class TagCommand(Command):
...
@@ -23,7 +23,8 @@ class TagCommand(Command):
p_out
=
lambda
a
:
None
,
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_prompt
=
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
=
False
self
.
force_add
=
False
self
.
force_add
=
False
...
@@ -31,10 +32,11 @@ class TagCommand(Command):
...
@@ -31,10 +32,11 @@ class TagCommand(Command):
self
.
tag
=
None
self
.
tag
=
None
self
.
value
=
None
self
.
value
=
None
self
.
values
=
[]
self
.
values
=
[]
self
.
current_values
=
[]
def
_process_flags
(
self
):
def
_process_flags
(
self
):
flags
,
args
=
self
.
getopt
(
"af"
)
flags
,
args
=
self
.
getopt
(
"af"
)
for
flag
,
value
in
flags
:
for
flag
,
_
in
flags
:
if
flag
==
"-a"
:
if
flag
==
"-a"
:
self
.
force_add
=
True
self
.
force_add
=
True
elif
flag
==
"-f"
:
elif
flag
==
"-f"
:
...
@@ -70,7 +72,8 @@ class TagCommand(Command):
...
@@ -70,7 +72,8 @@ class TagCommand(Command):
for
i
,
value
in
enumerate
(
self
.
current_values
):
for
i
,
value
in
enumerate
(
self
.
current_values
):
self
.
out
(
"%2d. %s"
%
(
i
+
1
,
value
))
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"
:
if
answer
!=
"all"
:
try
:
try
:
...
@@ -118,9 +121,12 @@ class TagCommand(Command):
...
@@ -118,9 +121,12 @@ class TagCommand(Command):
return
"""Synopsis: tag [-a] [-f] <NUMBER> <tag> [<value>]"""
return
"""Synopsis: tag [-a] [-f] <NUMBER> <tag> [<value>]"""
def
help
(
self
):
def
help
(
self
):
return
"""Sets the given tag to the given todo number with the given value. If
return
"""
\
the value is omitted, the tag is removed from the todo item.
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.
-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):
...
@@ -145,7 +145,8 @@ class TodoList(TodoListBase.TodoListBase):
Returns a list of parent todos that (in)directly depend on the
Returns a list of parent todos that (in)directly depend on the
given todo.
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
]
return
[
self
.
_tododict
[
parent
]
for
parent
in
parents
]
def
children
(
self
,
p_todo
,
p_only_direct
=
False
):
def
children
(
self
,
p_todo
,
p_only_direct
=
False
):
...
@@ -167,7 +168,9 @@ class TodoList(TodoListBase.TodoListBase):
...
@@ -167,7 +168,9 @@ class TodoList(TodoListBase.TodoListBase):
"""
"""
def
clean_by_tag
(
tag_name
):
def
clean_by_tag
(
tag_name
):
""" Generic function to handle 'p' and 'id' tags. """
""" 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
)
value
=
todo
.
tag_value
(
tag_name
)
if
not
self
.
_depgraph
.
has_edge_id
(
value
):
if
not
self
.
_depgraph
.
has_edge_id
(
value
):
todo
.
remove_tag
(
tag_name
,
value
)
todo
.
remove_tag
(
tag_name
,
value
)
...
...
topydo/lib/TodoListBase.py
View file @
43c6beee
...
@@ -185,7 +185,8 @@ class TodoListBase(object):
...
@@ -185,7 +185,8 @@ class TodoListBase(object):
A filter for the pretty printer to append the todo number to the
A filter for the pretty printer to append the todo number to the
printed todo.
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):
def __str__(self):
return '
\
n
'.join(pretty_print_list(self._todos))
return '
\
n
'.join(pretty_print_list(self._todos))
...
...
topydo/lib/TodoParser.py
View file @
43c6beee
...
@@ -23,12 +23,19 @@ import re
...
@@ -23,12 +23,19 @@ import re
import
Utils
import
Utils
_date_match
=
r'\
d{
4}-\
d{
2}-\
d{
2}'
_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
>
.
*
)
')
_COMPLETED_HEAD_MATCH
=
re
.
compile
(
_tag_match = re.compile('
(
?
P
<
key
>
[
^
:]
*
):(
?
P
<
value
>
.
*
)
')
r'x ((?P<completionDate>'
+
_DATE_MATCH
+
') )'
+
'((?P<creationDate>'
+
_project_match = re.compile(r'
\
+
(
\
S
*
\
w
)
')
_DATE_MATCH
+
') )?(?P<rest>.*)'
)
_context_match = re.compile(r'
@
(
\
S
*
\
w
)
')
_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):
def parse_line(p_string):
"""
"""
...
@@ -52,8 +59,8 @@ def parse_line(p_string):
...
@@ -52,8 +59,8 @@ def parse_line(p_string):
'
tags
': []
'
tags
': []
}
}
completed_head = _
completed_head_match
.match(p_string)
completed_head = _
COMPLETED_HEAD_MATCH
.match(p_string)
normal_head = _
normal_head_match
.match(p_string)
normal_head = _
NORMAL_HEAD_MATCH
.match(p_string)
rest = p_string
rest = p_string
...
@@ -76,15 +83,15 @@ def parse_line(p_string):
...
@@ -76,15 +83,15 @@ def parse_line(p_string):
rest = normal_head.group('
rest
')
rest = normal_head.group('
rest
')
for word in rest.split():
for word in rest.split():
project = _
project_match
.match(word)
project = _
PROJECT_MATCH
.match(word)
if project:
if project:
result['
projects
'].append(project.group(1))
result['
projects
'].append(project.group(1))
context = _
context_match
.match(word)
context = _
CONTEXT_MATCH
.match(word)
if context:
if context:
result['
contexts
'].append(context.group(1))
result['
contexts
'].append(context.group(1))
tag = _
tag_match
.match(word)
tag = _
TAG_MATCH
.match(word)
if tag:
if tag:
result['
tags
'].append((tag.group('
key
'), tag.group('
value
')))
result['
tags
'].append((tag.group('
key
'), tag.group('
value
')))
continue
continue
...
...
topydo/lib/View.py
View file @
43c6beee
...
@@ -44,7 +44,7 @@ class View(object):
...
@@ -44,7 +44,7 @@ class View(object):
def
pretty_print
(
self
,
p_pp_filters
=
[]):
def
pretty_print
(
self
,
p_pp_filters
=
[]):
""" Pretty prints the view. """
""" 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
))
return
'
\
n
'
.
join
(
pretty_print_list
(
self
.
_viewdata
,
pp_filters
))
def
__str__
(
self
):
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