def print_todos(self): """ Returns a pretty-printed string (without colors) of the todo items in this list. """ printer = PrettyPrinter() return printer.print_list(self._todos)
def execute_specific(self, p_todo): """ Actions specific to this command. """ self._handle_recurrence(p_todo) self.execute_specific_core(p_todo) printer = PrettyPrinter() self.out(self.prefix() + printer.print_todo(p_todo))
def _handle_recurrence(self, p_todo): if p_todo.has_tag('rec'): try: new_todo = advance_recurring_todo( p_todo, p_offset=self.completion_date, p_strict=self.strict_recurrence ) self.todolist.add_todo(new_todo) printer = PrettyPrinter() printer.add_filter(PrettyPrinterNumbers(self.todolist)) self.out(printer.print_todo(new_todo)) except NoRecurrenceException: self.error("Warning: todo item has an invalid recurrence pattern.")
def __init__(self, p_args, p_todolist, p_out=lambda a: None, p_err=lambda a: None, p_prompt=lambda a: None): """ Sets up the basic properties for executing a subcommand. p_args is a list of arguments that can be passed to this subcommand. These can be retrieved with argument(). p_todolist is a reference to the todolist instance to operate on. p_out is a function to be called to print (standard) output. Defaults to a noop. p_err is a function to be called to print errors. Defaults to a noop. p_prompt is a function that accepts a prompt string as its own argument and returns the answer to that prompt (normally entered by the user in some way). The default is a noop prompt. """ self.args = p_args self.todolist = p_todolist # inputs and outputs self.out = p_out self.error = p_err self.prompt = p_prompt # make pretty printer available self.printer = PrettyPrinter()
def pretty_print(self, p_pp_filters=None): """ Pretty prints the view. """ p_pp_filters = p_pp_filters or [] # since we're using filters, always use PrettyPrinter printer = PrettyPrinter() printer.add_filter(PrettyPrinterNumbers(self._todolist)) printer.add_filter(PrettyPrinterColorFilter()) for ppf in p_pp_filters: printer.add_filter(ppf) return printer.print_list(self._viewdata)
def _handle_recurrence(self, p_todo): if p_todo.has_tag('rec'): try: if self.strict_recurrence: new_todo = strict_advance_recurring_todo(p_todo, self.completion_date) else: new_todo = advance_recurring_todo(p_todo, self.completion_date) self.todolist.add_todo(new_todo) printer = PrettyPrinter() printer.add_filter(PrettyPrinterNumbers(self.todolist)) self.out(printer.print_todo(new_todo)) except NoRecurrenceException: self.error("Warning: todo item has an invalid recurrence pattern.")
def __init__(self, p_sorter, p_filters, p_todolist, p_printer=PrettyPrinter()): self._todolist = p_todolist self._viewdata = [] self._sorter = p_sorter self._filters = p_filters self._printer = p_printer self.update()
def __str__(self): printer = PrettyPrinter() return printer.print_list(self._todos)
def _print_list(self, p_todos): printer = PrettyPrinter() printer.add_filter(PrettyPrinterNumbers(self.todolist)) self.out(printer.print_list(p_todos))
def print_view(p_view): printer = PrettyPrinter() return "\n".join([str(s) for s in printer.print_list(p_view.todos)])
def print_view(p_view): printer = PrettyPrinter() return printer.print_list(p_view.todos)