Exemple #1
0
 def update_todo_plan_date(self, todo, planned_date):
     """Set the planning date for a task, selected by natural language."""
     selected_todo = self.match_todo_by_string(todo)['todo']
     parsed_date = parse_datetime(planned_date)
     print "Change do-date of '%s' to %s?" % (selected_todo['text'],
                                              pretty.date(parsed_date))
     if confirm(resp=True):
         selected_todo.set_planning_date(parsed_date, update=True)
Exemple #2
0
 def group_plan_date(todo):
     """
     Extract a pretty date, with all past dates listed 'OVERDUE'.
     """
     plan_date = todo.get_planning_date()
     if plan_date:
         if plan_date.date() < datetime.datetime.now().date():
             return "OVERDUE"
         else:
             return pretty.date(plan_date.date())
     else:
         return "Unplanned"
Exemple #3
0
    def get_todo_str(self,
                     todo,
                     date=False,
                     completed_faint=False,
                     notes=False):
        """Get a nicely formatted and colored string describing a task."""
        todo_str = "%-*s" % (40, todo['text'])

        # If dates should be printed, add the planning and drop-dead dates
        if date:
            plan_date = ""
            plan_date_obj = todo.get_planning_date()
            if plan_date_obj:
                plan_date = pretty.date(plan_date_obj)

            due = ""
            if 'date' in todo.keys() and todo['date']:
                dt_obj = dateutil.parser.parse(todo['date'])
                due = pretty.date(dt_obj)

            todo_str += " Plan: %-*s Due:%-*s" % (15, plan_date, 15, due)

        # Underline the string if the task is urgent
        tags = [tag for tag in todo['tags'].keys() if todo['tags'][tag]]
        if 'urgent' in [self.user['tag_dict'][tag] for tag in tags]:
            todo_str = colors.underline(todo_str)

        # Make the string faint if it has been completed
        if completed_faint:
            if 'completed' in todo.keys() and todo['completed']:
                todo_str = colors.faint(todo_str)

        # Format the notes as an indented block of text
        if notes:
            wrapper = textwrap.TextWrapper(initial_indent=" "*4,
                                           subsequent_indent=""*4)
            todo_str += "\n" + wrapper.fill(todo['notes'])

        return todo_str