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
317c71fc
Commit
317c71fc
authored
Jul 20, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add dep subcommand to handle dependencies.
parent
b9c7ed1d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
Main.py
Main.py
+55
-0
No files found.
Main.py
View file @
317c71fc
...
@@ -10,6 +10,7 @@ from PrettyPrinter import pretty_print
...
@@ -10,6 +10,7 @@ from PrettyPrinter import pretty_print
import
Sorter
import
Sorter
import
TodoFile
import
TodoFile
import
TodoList
import
TodoList
import
View
def
print_iterable
(
p_iter
):
def
print_iterable
(
p_iter
):
""" Prints an iterable to the standard output, one item per line. """
""" Prints an iterable to the standard output, one item per line. """
...
@@ -74,6 +75,58 @@ class Application(object):
...
@@ -74,6 +75,58 @@ class Application(object):
self
.
dirty
=
True
self
.
dirty
=
True
def
dep
(
self
):
""" Handles dependencies between todos. """
def
handle_add_rm
(
operation
):
""" Handles the add and rm subsubcommands. """
from_todonumber
=
convert_number
(
argument
(
3
))
to_todonumber
=
argument
(
4
)
if
to_todonumber
==
'to'
:
to_todonumber
=
convert_number
(
argument
(
5
))
else
:
to_todonumber
=
convert_number
(
to_todonumber
)
if
operation
==
'add'
:
self
.
todolist
.
add_dependency
(
from_todonumber
,
to_todonumber
)
else
:
self
.
todolist
.
remove_dependency
(
from_todonumber
,
to_todonumber
)
self
.
dirty
=
True
def
handle_ls
():
""" Handles the ls subsubcommand. """
arg1
=
argument
(
3
)
arg2
=
argument
(
4
)
todos
=
[]
if
arg2
==
'to'
:
# dep ls 1 to ...
todos
=
self
.
todolist
.
children
(
convert_number
(
arg1
))
elif
arg1
==
'to'
:
# dep ls ... to 1
todos
=
self
.
todolist
.
parents
(
convert_number
(
arg2
))
else
:
usage
()
if
todos
:
sorter
=
Sorter
.
Sorter
(
Config
.
SORT_STRING
)
view
=
View
.
View
(
sorter
,
[],
todos
)
print
view
.
pretty_print
()
subsubcommand
=
argument
(
2
)
if
subsubcommand
==
'add'
or
\
subsubcommand
==
'rm'
or
subsubcommand
==
'del'
:
handle_add_rm
(
subsubcommand
)
elif
subsubcommand
==
'clean'
or
subsubcommand
==
'gc'
:
self
.
todolist
.
clean_dependencies
()
self
.
dirty
=
True
elif
subsubcommand
==
'ls'
:
handle_ls
()
else
:
usage
()
def
do
(
self
):
def
do
(
self
):
number
=
convert_number
(
argument
(
2
))
number
=
convert_number
(
argument
(
2
))
todo
=
self
.
todolist
.
todo
(
number
)
todo
=
self
.
todolist
.
todo
(
number
)
...
@@ -127,6 +180,8 @@ class Application(object):
...
@@ -127,6 +180,8 @@ class Application(object):
self
.
add
()
self
.
add
()
elif
subcommand
==
'app'
or
subcommand
==
'append'
:
elif
subcommand
==
'app'
or
subcommand
==
'append'
:
self
.
append
()
self
.
append
()
elif
subcommand
==
'dep'
:
self
.
dep
()
elif
subcommand
==
'do'
:
elif
subcommand
==
'do'
:
self
.
do
()
self
.
do
()
elif
subcommand
==
'ls'
:
elif
subcommand
==
'ls'
:
...
...
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