def _handle_ls(self): """ Handles the ls subsubcommand. """ try: arg1 = self.argument(1) arg2 = self.argument(2) todos = [] if arg2 == 'to': # dep ls 1 to ... number = arg1 todo = self.todolist.todo(number) todos = self.todolist.children(todo) elif arg1 == 'to': # dep ls ... to 1 number = arg2 todo = self.todolist.todo(number) todos = self.todolist.parents(todo) else: self.error(self.usage()) if todos: sorter = Sorter(config().sort_string()) instance_filter = Filter.InstanceFilter(todos) view = View(sorter, [instance_filter], self.todolist) self.out(self.printer.print_list(view.todos)) except InvalidTodoException: self.error("Invalid todo number given.") except InvalidCommandArgument: self.error(self.usage())
def view(self, p_sorter, p_filters): """ Constructs a view of the todo list. A view is a sorted and filtered todo list, where the properties are defined by the end user. Todos is this list should not be modified, modifications should occur through this class. """ return View(p_sorter, p_filters, self)
def _view(self): sorter = Sorter(self.sort_expression) filters = self._filters() return View(sorter, filters, self.todolist)