From 17cc3a8418a8d55a94113871d68458ac53435850 Mon Sep 17 00:00:00 2001 From: Hoffelhas Date: Sat, 16 Jan 2021 15:54:21 +0100 Subject: [PATCH] Wrong warning message was given for a different kind of wrong syntax; additional warning added. --- autodoist.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/autodoist.py b/autodoist.py index 72a3348..30c1804 100644 --- a/autodoist.py +++ b/autodoist.py @@ -27,7 +27,7 @@ def make_wide(formatter, w=120, h=36): def main(): # Version - current_version = 'v1.4' + current_version = 'v1.4.1' """Main process function.""" parser = argparse.ArgumentParser( @@ -471,6 +471,10 @@ def main(): for item in items: active_type = None # Reset + # notes = api.notes.all() TODO: Quick notes test to see what the impact is? + # note_content = [x['content'] for x in notes if x['item_id'] == item['id']] + # print(note_content) + # Determine which child_items exist, both all and the ones that have not been checked yet non_checked_items = list( filter(lambda x: x['checked'] == 0, items)) @@ -712,7 +716,7 @@ def main(): except: logging.warning( - 'Wrong start-date format for item: %s. Please use "start="', item['content']) + 'Wrong start-date format for item: "%s". Please use "start="', item['content']) continue # Recurring task friendly - remove label with relative change from due date @@ -729,8 +733,13 @@ def main(): else: offset = item['content'][f+10:-1] - item_due_date = item['due']['date'] - item_due_date = datetime.strptime(item_due_date, '%Y-%m-%d') + try: + item_due_date = item['due']['date'] + item_due_date = datetime.strptime(item_due_date, '%Y-%m-%d') + except: + logging.warning('No due date to determine start date for item: "%s".', item['content']) + continue + if f1a != f1b and f1b > -1: # To make sure it doesn't trigger if 'w' is chosen td = timedelta(days=int(offset)) elif f2 > -1: