diff --git a/autodoist.py b/autodoist.py index 4b5ef13..08d881c 100644 --- a/autodoist.py +++ b/autodoist.py @@ -1156,48 +1156,47 @@ def autodoist_magic(args, api, connection): # Remove labels based on start / due dates # If task is too far in the future, remove the next_action tag and skip #TODO: FIX THIS - # try: - # if args.hide_future > 0 and 'due' in task.data and task.due is not None: - # due_date = datetime.strptime( - # task.due['date'][:10], "%Y-%m-%d") - # future_diff = ( - # due_date - datetime.today()).days - # if future_diff >= args.hide_future: - # remove_label( - # task, next_action_label, overview_task_ids, overview_task_labels) - # continue - # except: - # # Hide-future not set, skip - # continue + try: + if args.hide_future > 0 and task.due.date is not None: + due_date = datetime.strptime( + task.due.date, "%Y-%m-%d") + future_diff = ( + due_date - datetime.today()).days + if future_diff >= args.hide_future: + remove_label( + task, next_action_label, overview_task_ids, overview_task_labels) + except: + # Hide-future not set, skip + pass # If start-date has not passed yet, remove label #TODO: FIX THIS - # try: - # f1 = task.content.find('start=') - # f2 = task.content.find('start=due-') - # if f1 > -1 and f2 == -1: - # f_end = task.content[f1+6:].find(' ') - # if f_end > -1: - # start_date = task.content[f1 + - # 6:f1+6+f_end] - # else: - # start_date = task.content[f1+6:] + try: + f1 = task.content.find('start=') + f2 = task.content.find('start=due-') + if f1 > -1 and f2 == -1: + f_end = task.content[f1+6:].find(' ') + if f_end > -1: + start_date = task.content[f1 + + 6:f1+6+f_end] + else: + start_date = task.content[f1+6:] - # # If start-date hasen't passed, remove all labels - # start_date = datetime.strptime( - # start_date, args.dateformat) - # future_diff = ( - # datetime.today()-start_date).days - # if future_diff < 0: - # remove_label( - # task, next_action_label, overview_task_ids, overview_task_labels) - # [remove_label(child_task, next_action_label, overview_task_ids, - # overview_task_labels) for child_task in child_tasks] - # continue + # If start-date hasen't passed, remove all labels + start_date = datetime.strptime( + start_date, args.dateformat) + future_diff = ( + datetime.today()-start_date).days + if future_diff < 0: + remove_label( + task, next_action_label, overview_task_ids, overview_task_labels) + [remove_label(child_task, next_action_label, overview_task_ids, + overview_task_labels) for child_task in child_tasks] + pass - # except: - # logging.warning( - # 'Wrong start-date format for task: "%s". Please use "start="', task.content) - # continue + except: + logging.warning( + 'Wrong start-date format for task: "%s". Please use "start="', task.content) + continue # Recurring task friendly - remove label with relative change from due date #TODO FIX THIS # try: