Compare commits

...

5 Commits
master ... dev

1 changed files with 14 additions and 12 deletions

View File

@ -378,10 +378,12 @@ def check_header(level):
method = 0 method = 0
try: try:
# Support for legacy structure
name = level['name'] name = level['name']
method = 1 method = 1
except: except:
try: try:
# Current structure
content = level['content'] content = level['content']
method = 2 method = 2
except: except:
@ -391,14 +393,14 @@ def check_header(level):
if name[:3] == '** ': if name[:3] == '** ':
header_all_in_level = True header_all_in_level = True
level.update(name=name[3:]) level.update(name=name[3:])
if name[:3] == '!* ': if name[:3] == '!* ' or name[:3] == '_* ':
unheader_all_in_level = True unheader_all_in_level = True
level.update(name=name[3:]) level.update(name=name[3:])
elif method == 2: elif method == 2:
if content[:3] == '** ': if content[:3] == '** ':
header_all_in_level = True header_all_in_level = True
level.update(content=content[3:]) level.update(content=content[3:])
if content[:3] == '!* ': if content[:3] == '!* ' or content[:3] == '_* ':
unheader_all_in_level = True unheader_all_in_level = True
level.update(content=content[3:]) level.update(content=content[3:])
else: else:
@ -451,11 +453,7 @@ def run_recurring_lists_logic(args, api, item, child_items, child_items_all, reg
if item['due']['is_recurring']: if item['due']['is_recurring']:
try: try:
# Check if the T0 task date has changed # Check if the T0 task date has changed
if item['due']['date'] != item['date_old']: if item['due']['date'][:10] != item['date_old']:
# Save the new date for reference us
item.update(
date_old=item['due']['date'])
# Mark children for action based on mode # Mark children for action based on mode
if args.regeneration is not None: if args.regeneration is not None:
@ -497,9 +495,9 @@ def run_recurring_lists_logic(args, api, item, child_items, child_items_all, reg
# Determine the difference in days set by todoist # Determine the difference in days set by todoist
nd = [ nd = [
int(x) for x in item['due']['date'].split('-')] int(x) for x in item['due']['date'][:10].split('-')]
od = [ od = [
int(x) for x in item['date_old'].split('-')] int(x) for x in item['date_old'][:10].split('-')]
new_date = datetime( new_date = datetime(
nd[0], nd[1], nd[2]) nd[0], nd[1], nd[2])
@ -529,11 +527,15 @@ def run_recurring_lists_logic(args, api, item, child_items, child_items_all, reg
item.update(due=item_due) item.update(due=item_due)
# item.update(due={'date': '2020-05-29', 'is_recurring': True, 'string': 'every day'}) # item.update(due={'date': '2020-05-29', 'is_recurring': True, 'string': 'every day'})
# Save the new date for reference us
item.update(
date_old=item['due']['date'][:10])
except: except:
# If date has never been saved before, create a new entry # If date has never been saved before, create a new entry
logging.debug( logging.debug(
'New recurring task detected: %s' % item['content']) 'New recurring task detected: %s' % item['content'])
item['date_old'] = item['due']['date'] item['date_old'] = item['due']['date'][:10]
api.items.update(item['id']) api.items.update(item['id'])
except: except:
@ -802,7 +804,7 @@ def autodoist_magic(args, api, label_id, regen_labels_id):
try: try:
if args.hide_future > 0 and 'due' in item.data and item['due'] is not None: if args.hide_future > 0 and 'due' in item.data and item['due'] is not None:
due_date = datetime.strptime( due_date = datetime.strptime(
item['due']['date'], "%Y-%m-%d") item['due']['date'][:10], "%Y-%m-%d")
future_diff = ( future_diff = (
due_date - datetime.today()).days due_date - datetime.today()).days
if future_diff >= args.hide_future: if future_diff >= args.hide_future:
@ -859,7 +861,7 @@ def autodoist_magic(args, api, label_id, regen_labels_id):
offset = item['content'][f+10:-1] offset = item['content'][f+10:-1]
try: try:
item_due_date = item['due']['date'] item_due_date = item['due']['date'][:10]
item_due_date = datetime.strptime( item_due_date = datetime.strptime(
item_due_date, '%Y-%m-%d') item_due_date, '%Y-%m-%d')
except: except: