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):
priority = self.args[-1]
if len(numbers) > 0:
todos = []
for number in numbers:
todos.append(self.todolist.todo(number))
todos = [self.todolist.todo(number) for number in numbers]
if is_valid_priority(priority):
for todo in todos:
......@@ -57,9 +55,7 @@ class PriorityCommand(Command):
self.error("Invalid priority given.")
else:
self.error(self.usage())
except IndexError:
self.error(self.usage())
except InvalidCommandArgument:
except (IndexError, InvalidCommandArgument):
self.error(self.usage())
except (InvalidTodoException):
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