Exemple #1
0
    def execute(self):
        if not super().execute():
            return False

        try:
            number = self.argument(0)
            text = " ".join(self.args[1:])

            if text:
                todo = self.todolist.todo(number)
                new_text_parsed = parse_line(text)
                new_tags = new_text_parsed['tags']
                for tag in (config().tag_start(), config().tag_due()):
                    if tag in new_tags:
                        todo.remove_tag(tag)
                self.todolist.append(todo, text)
                self.postprocess_input_todo(todo)

                self.printer.add_filter(PrettyPrinterNumbers(self.todolist))
                self.out(self.printer.print_todo(todo))
            else:
                self.error(self.usage())
        except InvalidCommandArgument:
            self.error(self.usage())
        except InvalidTodoException:
            self.error("Invalid todo number given.")
Exemple #2
0
    def execute(self):
        if not super().execute():
            return False

        try:
            number = self.argument(0)
            text = " ".join(self.args[1:])

            if text:
                todo = self.todolist.todo(number)
                new_text_parsed = parse_line(text)
                new_tags = new_text_parsed['tags']
                for tag in (config().tag_start(), config().tag_due()):
                    if tag in new_tags:
                        todo.remove_tag(tag)
                self.todolist.append(todo, text)
                self.postprocess_input_todo(todo)

                self.printer.add_filter(PrettyPrinterNumbers(self.todolist))
                self.out(self.printer.print_todo(todo))
            else:
                self.error(self.usage())
        except InvalidCommandArgument:
            self.error(self.usage())
        except InvalidTodoException:
            self.error("Invalid todo number given.")
Exemple #3
0
def _parse_file(todofile: Path) -> Results:
    for line in todofile.open():
        try:
            t = parse_line(line)
            yield Todo(
                completed=t["completed"],
                completion_date=t["completionDate"],
                creation_date=t["creationDate"],
                priority=t["priority"],
                text=t["text"],
                projects=t["projects"],
                contexts=t["contexts"],
                tags=t["tags"],
            )
        except Exception as e:
            yield e
Exemple #4
0
 def set_source_text(self, p_text):
     """ Sets the todo source text. The text will be parsed again. """
     self.src = p_text.strip()
     self.fields = parse_line(self.src)
Exemple #5
0
 def set_source_text(self, p_text):
     """ Sets the todo source text. The text will be parsed again. """
     self.src = p_text.strip()
     self.fields = parse_line(self.src)