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
4efef4ec
Commit
4efef4ec
authored
Jun 08, 2015
by
Jacek Sowiński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove no longer needed IndexError exceptions
MultiCommand._catch_todo_errors() prevents occuring of those.
parent
4d049970
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
53 deletions
+42
-53
topydo/commands/DepriCommand.py
topydo/commands/DepriCommand.py
+6
-10
topydo/commands/PostponeCommand.py
topydo/commands/PostponeCommand.py
+19
-23
topydo/commands/PriorityCommand.py
topydo/commands/PriorityCommand.py
+17
-20
No files found.
topydo/commands/DepriCommand.py
View file @
4efef4ec
...
@@ -26,17 +26,13 @@ class DepriCommand(MultiCommand):
...
@@ -26,17 +26,13 @@ class DepriCommand(MultiCommand):
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
def
execute_multi_specific
(
self
):
def
execute_multi_specific
(
self
):
try
:
self
.
printer
.
add_filter
(
PrettyPrinterNumbers
(
self
.
todolist
))
self
.
printer
.
add_filter
(
PrettyPrinterNumbers
(
self
.
todolist
))
for
todo
in
self
.
todos
:
for
todo
in
self
.
todos
:
if
todo
.
priority
()
!=
None
:
if
todo
.
priority
()
!=
None
:
self
.
todolist
.
set_priority
(
todo
,
None
)
self
.
todolist
.
set_priority
(
todo
,
None
)
self
.
out
(
"Priority removed."
)
self
.
out
(
"Priority removed."
)
self
.
out
(
self
.
printer
.
print_todo
(
todo
))
self
.
out
(
self
.
printer
.
print_todo
(
todo
))
except
IndexError
:
self
.
error
(
self
.
usage
())
def
usage
(
self
):
def
usage
(
self
):
return
"""Synopsis: depri <NUMBER1> [<NUMBER2> ...]"""
return
"""Synopsis: depri <NUMBER1> [<NUMBER2> ...]"""
...
...
topydo/commands/PostponeCommand.py
View file @
4efef4ec
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
from
datetime
import
date
,
timedelta
from
datetime
import
date
,
timedelta
from
topydo.lib.MultiCommand
import
MultiCommand
from
topydo.lib.MultiCommand
import
MultiCommand
from
topydo.lib.Command
import
InvalidCommandArgument
from
topydo.lib.Config
import
config
from
topydo.lib.Config
import
config
from
topydo.lib.PrettyPrinterFilter
import
PrettyPrinterNumbers
from
topydo.lib.PrettyPrinterFilter
import
PrettyPrinterNumbers
from
topydo.lib.RelativeDate
import
relative_date_to_date
from
topydo.lib.RelativeDate
import
relative_date_to_date
...
@@ -52,31 +51,28 @@ class PostponeCommand(MultiCommand):
...
@@ -52,31 +51,28 @@ class PostponeCommand(MultiCommand):
return
offset_date
return
offset_date
try
:
pattern
=
self
.
args
[
-
1
]
pattern
=
self
.
args
[
-
1
]
self
.
printer
.
add_filter
(
PrettyPrinterNumbers
(
self
.
todolist
))
self
.
printer
.
add_filter
(
PrettyPrinterNumbers
(
self
.
todolist
))
for
todo
in
self
.
todos
:
for
todo
in
self
.
todos
:
offset
=
_get_offset
(
todo
)
offset
=
_get_offset
(
todo
)
new_due
=
relative_date_to_date
(
pattern
,
offset
)
new_due
=
relative_date_to_date
(
pattern
,
offset
)
if
new_due
:
if
self
.
move_start_date
and
todo
.
has_tag
(
config
().
tag_start
()):
length
=
todo
.
length
()
new_start
=
new_due
-
timedelta
(
length
)
# pylint: disable=E1103
todo
.
set_tag
(
config
().
tag_start
(),
new_start
.
isoformat
())
if
new_due
:
if
self
.
move_start_date
and
todo
.
has_tag
(
config
().
tag_start
()):
length
=
todo
.
length
()
new_start
=
new_due
-
timedelta
(
length
)
# pylint: disable=E1103
# pylint: disable=E1103
todo
.
set_tag
(
config
().
tag_due
(),
new_due
.
isoformat
())
todo
.
set_tag
(
config
().
tag_start
(),
new_start
.
isoformat
())
self
.
todolist
.
set_dirty
()
# pylint: disable=E1103
self
.
out
(
self
.
printer
.
print_todo
(
todo
))
todo
.
set_tag
(
config
().
tag_due
(),
new_due
.
isoformat
())
else
:
self
.
error
(
"Invalid date pattern given."
)
self
.
todolist
.
set_dirty
()
break
self
.
out
(
self
.
printer
.
print_todo
(
todo
))
except
(
InvalidCommandArgument
,
IndexError
):
else
:
self
.
error
(
self
.
usage
())
self
.
error
(
"Invalid date pattern given."
)
break
def
usage
(
self
):
def
usage
(
self
):
return
"Synopsis: postpone [-s] <NUMBER> [<NUMBER2> ...] <PATTERN>"
return
"Synopsis: postpone [-s] <NUMBER> [<NUMBER2> ...] <PATTERN>"
...
...
topydo/commands/PriorityCommand.py
View file @
4efef4ec
...
@@ -31,26 +31,23 @@ class PriorityCommand(MultiCommand):
...
@@ -31,26 +31,23 @@ class PriorityCommand(MultiCommand):
def
execute_multi_specific
(
self
):
def
execute_multi_specific
(
self
):
priority
=
None
priority
=
None
try
:
priority
=
self
.
args
[
-
1
]
priority
=
self
.
args
[
-
1
]
self
.
printer
.
add_filter
(
PrettyPrinterNumbers
(
self
.
todolist
))
self
.
printer
.
add_filter
(
PrettyPrinterNumbers
(
self
.
todolist
))
if
is_valid_priority
(
priority
):
if
is_valid_priority
(
priority
):
for
todo
in
self
.
todos
:
for
todo
in
self
.
todos
:
old_priority
=
todo
.
priority
()
old_priority
=
todo
.
priority
()
self
.
todolist
.
set_priority
(
todo
,
priority
)
self
.
todolist
.
set_priority
(
todo
,
priority
)
if
old_priority
and
priority
and
old_priority
!=
priority
:
if
old_priority
and
priority
and
old_priority
!=
priority
:
self
.
out
(
"Priority changed from {} to {}"
.
format
(
self
.
out
(
"Priority changed from {} to {}"
.
format
(
old_priority
,
priority
))
old_priority
,
priority
))
elif
not
old_priority
:
elif
not
old_priority
:
self
.
out
(
"Priority set to {}."
.
format
(
priority
))
self
.
out
(
"Priority set to {}."
.
format
(
priority
))
self
.
out
(
self
.
printer
.
print_todo
(
todo
))
self
.
out
(
self
.
printer
.
print_todo
(
todo
))
else
:
else
:
self
.
error
(
"Invalid priority given."
)
self
.
error
(
"Invalid priority given."
)
except
IndexError
:
self
.
error
(
self
.
usage
())
def
usage
(
self
):
def
usage
(
self
):
return
"""Synopsis: pri <NUMBER1> [<NUMBER2> ...] <PRIORITY>"""
return
"""Synopsis: pri <NUMBER1> [<NUMBER2> ...] <PRIORITY>"""
...
...
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