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
5718e113
Commit
5718e113
authored
Mar 24, 2015
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8 from mruwek/multi-postpone
Give 'postpone' command possibility to work with multiple todos
parents
a9f29074
12869a01
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
23 deletions
+88
-23
test/PostponeCommandTest.py
test/PostponeCommandTest.py
+47
-0
topydo/lib/PostponeCommand.py
topydo/lib/PostponeCommand.py
+41
-23
No files found.
test/PostponeCommandTest.py
View file @
5718e113
...
...
@@ -164,6 +164,53 @@ class PostponeCommandTest(CommandTest.CommandTest):
self
.
assertEquals
(
self
.
output
,
"| 1| Foo due:{}
\
n
"
.
format
(
due
.
isoformat
()))
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_postpone14
(
self
):
command
=
PostponeCommand
([
"1"
,
"2"
,
"1w"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
due
=
self
.
today
+
timedelta
(
7
)
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
"| 1| Foo due:{}
\
n
| 2| Bar due:{}
\
n
"
.
format
(
due
.
isoformat
(),
due
.
isoformat
()))
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_postpone15
(
self
):
command
=
PostponeCommand
([
"Foo"
,
"2"
,
"1w"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
due
=
self
.
today
+
timedelta
(
7
)
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
"| 1| Foo due:{}
\
n
| 2| Bar due:{}
\
n
"
.
format
(
due
.
isoformat
(),
due
.
isoformat
()))
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_postpone16
(
self
):
command
=
PostponeCommand
([
"-s"
,
"2"
,
"3"
,
"1w"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
due
=
self
.
today
+
timedelta
(
7
)
start
=
self
.
start
+
timedelta
(
7
)
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
"| 2| Bar due:{}
\
n
| 3| Baz due:{} t:{}
\
n
"
.
format
(
due
.
isoformat
(),
due
.
isoformat
(),
start
.
isoformat
()))
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_postpone17
(
self
):
command
=
PostponeCommand
([
"1"
,
"2"
,
"3"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
"Invalid date pattern given.
\
n
"
)
def
test_postpone18
(
self
):
command
=
PostponeCommand
([
"1"
,
"99"
,
"123"
,
"1w"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
"Invalid todo number given: 99.
\
n
Invalid todo number given: 123.
\
n
"
)
def
test_help
(
self
):
command
=
PostponeCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
topydo/lib/PostponeCommand.py
View file @
5718e113
...
...
@@ -58,40 +58,58 @@ class PostponeCommand(Command):
self
.
_process_flags
()
try
:
todo
=
self
.
todolist
.
todo
(
self
.
argument
(
0
))
pattern
=
self
.
argument
(
1
)
todos
=
[]
invalid_numbers
=
[]
for
number
in
self
.
args
[:
-
1
]:
try
:
todos
.
append
(
self
.
todolist
.
todo
(
number
))
except
InvalidTodoException
:
invalid_numbers
.
append
(
number
)
if
len
(
invalid_numbers
)
>
0
and
len
(
todos
)
>
0
:
for
number
in
invalid_numbers
:
self
.
error
(
"Invalid todo number given: {}."
.
format
(
number
))
elif
len
(
invalid_numbers
)
==
1
and
len
(
todos
)
==
0
:
self
.
error
(
"Invalid todo number given."
)
else
:
offset
=
_get_offset
(
todo
)
new_due
=
relative_date_to_date
(
pattern
,
offset
)
try
:
pattern
=
self
.
args
[
-
1
]
if
new_due
:
if
self
.
move_start_date
and
todo
.
has_tag
(
config
().
tag_start
()):
length
=
todo
.
length
()
new_start
=
new_due
-
timedelta
(
length
)
todo
.
set_tag
(
config
().
tag_start
(),
new_start
.
isoformat
())
self
.
printer
.
add_filter
(
PrettyPrinterNumbers
(
self
.
todolist
))
todo
.
set_tag
(
config
().
tag_due
(),
new_due
.
isoformat
())
if
len
(
todos
)
>
0
:
for
todo
in
todos
:
offset
=
_get_offset
(
todo
)
new_due
=
relative_date_to_date
(
pattern
,
offset
)
self
.
todolist
.
set_dirty
()
self
.
printer
.
add_filter
(
PrettyPrinterNumbers
(
self
.
todolist
))
self
.
out
(
self
.
printer
.
print_todo
(
todo
)
)
else
:
self
.
error
(
"Invalid date pattern given."
)
if
new_due
:
if
self
.
move_start_date
and
todo
.
has_tag
(
config
().
tag_start
()):
length
=
todo
.
length
(
)
new_start
=
new_due
-
timedelta
(
length
)
todo
.
set_tag
(
config
().
tag_start
(),
new_start
.
isoformat
()
)
except
InvalidCommandArgument
:
self
.
error
(
self
.
usage
())
except
(
InvalidTodoException
):
self
.
error
(
"Invalid todo number given."
)
todo
.
set_tag
(
config
().
tag_due
(),
new_due
.
isoformat
())
self
.
todolist
.
set_dirty
()
self
.
out
(
self
.
printer
.
print_todo
(
todo
))
else
:
self
.
error
(
"Invalid date pattern given."
)
break
else
:
self
.
error
(
self
.
usage
())
except
(
InvalidCommandArgument
,
IndexError
):
self
.
error
(
self
.
usage
())
def
usage
(
self
):
return
"Synopsis: postpone [-s] <NUMBER> <PATTERN>"
return
"Synopsis: postpone [-s] <NUMBER>
[<NUMBER2> ...]
<PATTERN>"
def
help
(
self
):
return
"""
\
Postpone
a todo item with the given number
and the given pattern.
Postpone
the todo item(s) with the given number(s)
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
(s) of the todo(s)
, and if the -s flag is
given, the start date accordingly.
The pattern is a relative date, written in the format <COUNT><PERIOD> where
...
...
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