Commit 0593bfbd authored by Jacek Sowiński's avatar Jacek Sowiński

Small code refactoring

1. Shorter code for creating and populating 'todos' list
2. Merge IndexError and InvalidCommandArgument

@bram85: Thanks!
parent 47781baa
...@@ -37,9 +37,7 @@ class PriorityCommand(Command): ...@@ -37,9 +37,7 @@ class PriorityCommand(Command):
priority = self.args[-1] priority = self.args[-1]
if len(numbers) > 0: if len(numbers) > 0:
todos = [] todos = [self.todolist.todo(number) for number in numbers]
for number in numbers:
todos.append(self.todolist.todo(number))
if is_valid_priority(priority): if is_valid_priority(priority):
for todo in todos: for todo in todos:
...@@ -57,9 +55,7 @@ class PriorityCommand(Command): ...@@ -57,9 +55,7 @@ class PriorityCommand(Command):
self.error("Invalid priority given.") self.error("Invalid priority given.")
else: else:
self.error(self.usage()) self.error(self.usage())
except IndexError: except (IndexError, InvalidCommandArgument):
self.error(self.usage())
except InvalidCommandArgument:
self.error(self.usage()) self.error(self.usage())
except (InvalidTodoException): except (InvalidTodoException):
if len(numbers) > 0 and priority: if len(numbers) > 0 and priority:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment