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
aae4efa7
Commit
aae4efa7
authored
Oct 18, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Throw exception when an argument could not be found.
parent
3c7ef04b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
18 deletions
+19
-18
AppendCommand.py
AppendCommand.py
+14
-16
Command.py
Command.py
+5
-2
No files found.
AppendCommand.py
View file @
aae4efa7
import
Command
from
Command
import
*
from
PrettyPrinter
import
pretty_print
from
PrettyPrinter
import
pretty_print
import
TodoList
import
TodoList
from
Utils
import
convert_todo_number
,
InvalidTodoNumberException
from
Utils
import
convert_todo_number
,
InvalidTodoNumberException
class
AppendCommand
(
Command
.
Command
):
class
AppendCommand
(
Command
):
def
__init__
(
self
,
p_args
,
p_todolist
,
def
__init__
(
self
,
p_args
,
p_todolist
,
p_out
=
lambda
a
:
None
,
p_out
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
p_err
=
lambda
a
:
None
,
...
@@ -11,20 +11,18 @@ class AppendCommand(Command.Command):
...
@@ -11,20 +11,18 @@ class AppendCommand(Command.Command):
super
(
AppendCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
=
lambda
a
:
None
)
super
(
AppendCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
=
lambda
a
:
None
)
def
execute
(
self
):
def
execute
(
self
):
number
=
self
.
argument
(
0
)
try
:
if
number
:
number
=
convert_todo_number
(
self
.
argument
(
0
))
try
:
text
=
" "
.
join
(
self
.
args
[
1
:])
number
=
convert_todo_number
(
number
)
text
=
" "
.
join
(
self
.
args
[
1
:])
if
text
:
if
text
:
todo
=
self
.
todolist
.
todo
(
number
)
todo
=
self
.
todolist
.
todo
(
number
)
self
.
todolist
.
append
(
todo
,
text
)
self
.
todolist
.
append
(
todo
,
text
)
self
.
out
(
pretty_print
(
todo
,
[
self
.
todolist
.
pp_number
()]))
self
.
out
(
pretty_print
(
todo
,
[
self
.
todolist
.
pp_number
()]))
else
:
else
:
self
.
error
(
self
.
usage
())
except
InvalidTodoNumberException
:
self
.
error
(
self
.
usage
())
self
.
error
(
self
.
usage
())
except
TodoList
.
InvalidTodoException
:
except
(
InvalidCommandArgument
,
InvalidTodoNumberException
):
self
.
error
(
"Invalid todo number given."
)
self
.
error
(
self
.
usage
())
except
TodoList
.
InvalidTodoException
:
self
.
error
(
"Invalid todo number given."
)
Command.py
View file @
aae4efa7
class
InvalidCommandArgument
(
Exception
):
pass
class
Command
(
object
):
class
Command
(
object
):
def
__init__
(
self
,
p_args
,
p_todolist
,
def
__init__
(
self
,
p_args
,
p_todolist
,
p_out
=
lambda
a
:
None
,
p_out
=
lambda
a
:
None
,
...
@@ -37,13 +40,13 @@ class Command(object):
...
@@ -37,13 +40,13 @@ class Command(object):
"""
"""
return
False
return
False
def
argument
(
self
,
p_number
):
def
argument
(
self
,
p_number
,
p_error
=
None
):
""" Retrieves a value from the argument list at the given position. """
""" Retrieves a value from the argument list at the given position. """
value
=
None
value
=
None
try
:
try
:
value
=
self
.
args
[
p_number
]
value
=
self
.
args
[
p_number
]
except
IndexError
:
except
IndexError
:
self
.
error
(
self
.
usage
())
raise
InvalidCommandArgument
return
value
return
value
...
...
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