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
924c2d04
Commit
924c2d04
authored
Sep 27, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor _postprocess_input_todo.
parent
02247fef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
AddCommand.py
AddCommand.py
+17
-11
No files found.
AddCommand.py
View file @
924c2d04
...
@@ -18,7 +18,7 @@ class AddCommand(Command.Command):
...
@@ -18,7 +18,7 @@ class AddCommand(Command.Command):
"""
"""
self
.
text
=
re
.
sub
(
r'^(.+) (\
([A-Z]
\))(.*)$'
,
r'\2 \1\3'
,
self
.
text
)
self
.
text
=
re
.
sub
(
r'^(.+) (\
([A-Z]
\))(.*)$'
,
r'\2 \1\3'
,
self
.
text
)
def
_postprocess_input_todo
(
self
):
# TODO: split function
def
_postprocess_input_todo
(
self
):
"""
"""
Post-processes a parsed todo when adding it to the list.
Post-processes a parsed todo when adding it to the list.
...
@@ -26,29 +26,35 @@ class AddCommand(Command.Command):
...
@@ -26,29 +26,35 @@ class AddCommand(Command.Command):
* Automatically inserts a creation date if not present.
* Automatically inserts a creation date if not present.
* Handles more user-friendly dependencies with before: and after: tags
* Handles more user-friendly dependencies with before: and after: tags
"""
"""
for
tag
in
[
Config
.
TAG_START
,
Config
.
TAG_DUE
]
:
def
convert_date
(
p_tag
)
:
value
=
self
.
todo
.
tag_value
(
tag
)
value
=
self
.
todo
.
tag_value
(
p_
tag
)
if
value
:
if
value
:
dateobj
=
relative_date_to_date
(
value
)
dateobj
=
relative_date_to_date
(
value
)
if
dateobj
:
if
dateobj
:
self
.
todo
.
set_tag
(
tag
,
dateobj
.
isoformat
())
self
.
todo
.
set_tag
(
p_
tag
,
dateobj
.
isoformat
())
self
.
todo
.
set_creation_date
(
date
.
today
())
def
add_dependencies
(
p_tag
):
for
raw_value
in
self
.
todo
.
tag_values
(
p_tag
):
for
tag
in
[
'before'
,
'after'
]:
for
raw_value
in
self
.
todo
.
tag_values
(
tag
):
try
:
try
:
value
=
int
(
raw_value
)
value
=
int
(
raw_value
)
except
ValueError
:
except
ValueError
:
continue
continue
if
tag
==
'after'
:
if
p_
tag
==
'after'
:
self
.
todolist
.
add_dependency
(
self
.
todo
.
attributes
[
'number'
],
value
)
self
.
todolist
.
add_dependency
(
self
.
todo
.
attributes
[
'number'
],
value
)
elif
tag
==
'before'
:
elif
p_
tag
==
'before'
:
self
.
todolist
.
add_dependency
(
value
,
self
.
todo
.
attributes
[
'number'
])
self
.
todolist
.
add_dependency
(
value
,
self
.
todo
.
attributes
[
'number'
])
self
.
todo
.
remove_tag
(
tag
,
raw_value
)
self
.
todo
.
remove_tag
(
p_tag
,
raw_value
)
convert_date
(
Config
.
TAG_START
)
convert_date
(
Config
.
TAG_DUE
)
add_dependencies
(
'before'
)
add_dependencies
(
'after'
)
self
.
todo
.
set_creation_date
(
date
.
today
())
def
execute
(
self
):
def
execute
(
self
):
""" Adds a todo item to the list. """
""" Adds a todo item to the list. """
...
...
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