def get_dues(self, end_date=None): if (end_date != None): today = date_op.today() if (end_date == 'today'): end_date = today elif ('this month' in end_date): end_date = date_op.this_month() elif ('this week' in end_date): end_date = date_op.this_week() elif ('week' in end_date): end_date = date_op.add(today, None, None, 6) elif ('month' in end_date): end_date = date_op.add(today, None, 1, None) else: end_date = date_op.get_date(end_date) tasks = set() for key, value in sorted(self.todos['due'].iteritems(), key=lambda (k, v): (v, k)): if (end_date != None): due_date = date_op.get_date(self.todos['due'][key]) if (date_op.compare(due_date, end_date) <= 0): tasks.add(key) else: tasks.add(key) return tasks
def get_dues(self, end_date=None): if ( end_date != None ): today = date_op.today() if ( end_date == 'today' ): end_date = today elif ( 'this month' in end_date ): end_date = date_op.this_month() elif ( 'this week' in end_date ): end_date = date_op.this_week() elif ( 'week' in end_date ): end_date = date_op.add(today, None, None, 6) elif ( 'month' in end_date ): end_date = date_op.add(today, None, 1, None) else: end_date = date_op.get_date(end_date) tasks = set() for key,value in sorted(self.todos['due'].iteritems(), key=lambda(k,v):(v,k)): if ( end_date != None ): due_date = date_op.get_date(self.todos['due'][key]) if ( date_op.compare(due_date, end_date) <= 0 ): tasks.add(key) else: tasks.add(key) return tasks
def __get_date_pattern(self, task): today = date_op.today() date_pattern = { 'today':today, 'next week':date_op.add(today, None, None, 7), 'next month':date_op.add(today, None, 1, None), 'next year':date_op.add(today, 1, None, None)} for key in date_pattern.keys(): value = date_pattern[key] replace = re.sub('\^'+key+' ', '^'+value+' ', task) if ( replace != task ): break return replace
def __get_date_pattern(self, task): today = date_op.today() date_pattern = { 'today': today, 'next week': date_op.add(today, None, None, 7), 'next month': date_op.add(today, None, 1, None), 'next year': date_op.add(today, 1, None, None) } for key in date_pattern.keys(): value = date_pattern[key] replace = re.sub('\^' + key + ' ', '^' + value + ' ', task) if (replace != task): break return replace
def do_task(self, tid): recur = self.is_recur(tid) due_date = self.get_due(tid) next_due = None self.__task_done(tid) if (recur != None): if (recur == 'bimonthly'): next_due = date_op.add(due_date, None, 2, None) elif (recur == 'monthly'): next_due = date_op.add(due_date, None, 1, None) elif (recur == 'biweekly'): next_due = date_op.add(due_date, None, None, 14) new_task = self.replace_task(tid, due_date, next_due) self.add_task(new_task)
def do_task(self, tid): recur = self.is_recur(tid) due_date = self.get_due(tid) next_due = None self.__task_done(tid) if ( recur != None ): if ( recur == 'bimonthly' ): next_due = date_op.add(due_date, None, 2, None) elif ( recur == 'monthly' ): next_due = date_op.add(due_date, None, 1, None) elif ( recur == 'biweekly' ): next_due = date_op.add(due_date, None, None, 14) new_task = self.replace_task(tid, due_date, next_due) self.add_task(new_task)