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
f79f683c
Commit
f79f683c
authored
Sep 27, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add command for 'do'.
parent
c2037fc8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
29 deletions
+41
-29
DoCommand.py
DoCommand.py
+38
-0
Main.py
Main.py
+3
-29
No files found.
DoCommand.py
0 → 100644
View file @
f79f683c
import
re
import
Command
from
Recurrence
import
advance_recurring_todo
from
Utils
import
convert_todo_number
class
DoCommand
(
Command
.
Command
):
def
__init__
(
self
,
p_args
,
p_todolist
):
super
(
DoCommand
,
self
).
__init__
(
p_args
,
p_todolist
)
self
.
number
=
convert_todo_number
(
self
.
argument
(
0
))
self
.
todo
=
self
.
todolist
.
todo
(
self
.
number
)
def
_complete_children
(
self
):
children
=
[
t
.
attributes
[
'number'
]
for
t
in
self
.
todolist
.
children
(
self
.
number
)
if
not
t
.
is_completed
()]
if
children
:
for
child
in
children
:
# self.print_todo(child) # FIXME
pass
confirmation
=
raw_input
(
"Also mark subtasks as done? [n] "
);
# FIXME
if
re
.
match
(
'^y(es)?$'
,
confirmation
,
re
.
I
):
for
child
in
children
:
self
.
todolist
.
set_todo_completed
(
child
)
# self.print_todo(child) # FIXME
def
_handle_recurrence
(
self
):
if
self
.
todo
.
has_tag
(
'rec'
):
new_todo
=
advance_recurring_todo
(
self
.
todo
)
self
.
todolist
.
add_todo
(
new_todo
)
# self.print_todo(self.todolist.count()) # FIXME
def
execute
(
self
):
if
self
.
todo
and
not
self
.
todo
.
is_completed
():
self
.
_complete_children
()
self
.
_handle_recurrence
()
self
.
todolist
.
set_todo_completed
(
self
.
number
)
Main.py
View file @
f79f683c
...
...
@@ -7,10 +7,10 @@ import sys
from
AddCommand
import
AddCommand
from
AppendCommand
import
AppendCommand
from
DepCommand
import
DepCommand
from
DoCommand
import
DoCommand
import
Config
import
Filter
from
PrettyPrinter
import
pretty_print
from
Recurrence
import
advance_recurring_todo
import
Sorter
import
TodoFile
import
TodoList
...
...
@@ -78,34 +78,8 @@ class Application(object): # TODO: rename to CLIApplication
command
.
execute
()
def
do
(
self
):
def
complete_children
(
p_number
):
children
=
[
t
.
attributes
[
'number'
]
for
t
in
self
.
todolist
.
children
(
p_number
)
if
not
t
.
is_completed
()]
if
children
:
for
child
in
children
:
self
.
print_todo
(
child
)
confirmation
=
raw_input
(
"Also mark subtasks as done? [n] "
);
if
re
.
match
(
'^y(es)?$'
,
confirmation
,
re
.
I
):
for
child
in
children
:
self
.
todolist
.
todo
(
child
).
set_completed
()
self
.
print_todo
(
child
)
def
handle_recurrence
(
todo
):
if
todo
.
has_tag
(
'rec'
):
new_todo
=
advance_recurring_todo
(
todo
)
self
.
todolist
.
add_todo
(
new_todo
)
self
.
print_todo
(
self
.
todolist
.
count
())
number
=
convert_todo_number
(
argument
(
2
))
todo
=
self
.
todolist
.
todo
(
number
)
if
todo
and
not
todo
.
is_completed
():
complete_children
(
number
)
handle_recurrence
(
todo
)
todo
.
set_completed
()
self
.
print_todo
(
number
)
command
=
DoCommand
(
arguments
(),
self
.
todolist
)
command
.
execute
()
def
pri
(
self
):
number
=
convert_todo_number
(
argument
(
2
))
...
...
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