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
bce6f88d
Commit
bce6f88d
authored
Sep 21, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support before: and after: tags to enter dependencies while adding a todo.
parent
06af54b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
18 deletions
+34
-18
Main.py
Main.py
+34
-18
No files found.
Main.py
View file @
bce6f88d
...
...
@@ -61,28 +61,44 @@ def preprocess_input_todo(p_text):
return
p_text
def
postprocess_input_todo
(
p_todo
):
"""
Post-processes a parsed todo when adding it to the list.
* It converts relative dates to absolute ones.
* Automatically inserts a creation date if not present.
"""
for
tag
in
[
Config
.
TAG_START
,
Config
.
TAG_DUE
]:
value
=
p_todo
.
tag_value
(
tag
)
if
value
:
date
=
relative_date_to_date
(
value
)
if
date
:
p_todo
.
set_tag
(
tag
,
date
.
isoformat
())
p_todo
.
set_creation_date
(
date
.
today
())
class
Application
(
object
):
def
__init__
(
self
):
self
.
todolist
=
TodoList
.
TodoList
([])
self
.
dirty
=
False
def
_postprocess_input_todo
(
self
,
p_todo
):
"""
Post-processes a parsed todo when adding it to the list.
* It converts relative dates to absolute ones.
* Automatically inserts a creation date if not present.
* Handles more user-friendly dependencies with before: and after: tags
"""
for
tag
in
[
Config
.
TAG_START
,
Config
.
TAG_DUE
]:
value
=
p_todo
.
tag_value
(
tag
)
if
value
:
dateobj
=
relative_date_to_date
(
value
)
if
dateobj
:
p_todo
.
set_tag
(
tag
,
dateobj
.
isoformat
())
p_todo
.
set_creation_date
(
date
.
today
())
for
tag
in
[
'before'
,
'after'
]:
if
p_todo
.
has_tag
(
tag
):
try
:
raw_value
=
p_todo
.
tag_value
(
tag
)
value
=
int
(
raw_value
)
if
tag
==
'after'
:
self
.
todolist
.
add_dependency
(
p_todo
.
attributes
[
'number'
],
value
)
elif
tag
==
'before'
:
self
.
todolist
.
add_dependency
(
value
,
p_todo
.
attributes
[
'number'
])
p_todo
.
remove_tag
(
tag
,
raw_value
)
except
ValueError
:
pass
def
print_todo
(
self
,
p_number
):
""" Prints a single todo item to the standard output. """
todo
=
self
.
todolist
.
todo
(
p_number
)
...
...
@@ -93,7 +109,7 @@ class Application(object):
""" Adds a todo item to the list. """
text
=
preprocess_input_todo
(
argument
(
2
))
todo
=
self
.
todolist
.
add
(
text
)
postprocess_input_todo
(
todo
)
self
.
_
postprocess_input_todo
(
todo
)
self
.
print_todo
(
self
.
todolist
.
count
())
self
.
dirty
=
True
...
...
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