Pseudocode updated, section loop build-in, still need to build a class to handle 'no section' tasks, and finalize labeling logic

pull/15/head
Hoffelhas 2020-12-17 21:02:30 +01:00
parent a913c74086
commit 3943c5c614
1 changed files with 252 additions and 240 deletions

View File

@ -128,7 +128,7 @@ def main():
"\n\nNo API key set. Run Autodoist with '-a <YOUR_API_KEY>'\n") "\n\nNo API key set. Run Autodoist with '-a <YOUR_API_KEY>'\n")
sys.exit(1) sys.exit(1)
# Check if AEOD is used # Check if alternative end of day is used
if args.end is not None: if args.end is not None:
if args.end < 1 or args.end > 24: if args.end < 1 or args.end > 24:
logging.error( logging.error(
@ -374,10 +374,20 @@ def main():
project['name'], project_type) project['name'], project_type)
# Get all items for the project # Get all items for the project
items = api.items.all( # items = api.items.all(
lambda x: x['project_id'] == project['id']) # lambda x: x['project_id'] == project['id'])
sections = [x['section_id'] for x in items] # better than api.sections.all(lambda x: x['project_id'] == project['id']), since then NoneTypes are not shown sections = api.sections.all(lambda x: x['project_id'] == project['id'])
section_ids = [x['id'] for x in sections]
section_ids.insert(0,None)
add_empty_section(sections) # Build class
for section in sections:
# Get all items for the section
items = api.items.all(lambda x: x['section_id'] == section['id'])
# sections = [x['section_id'] for x in items] # better than api.sections.all(lambda x: x['project_id'] == project['id']), since then NoneTypes are not shown
# Change top parents_id in order to sort later on # Change top parents_id in order to sort later on
for item in items: for item in items:
@ -434,6 +444,16 @@ def main():
# 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'] != item['date_old']:
# Save the new date for reference us
item.update(
date_old=item['due']['date'])
# Mark children for action
if args.recurring:
for child_item in child_items_all:
child_item['r_tag'] = 1
# If alternative end of day, fix due date if needed
if args.end is not None: if args.end is not None:
# Determine current hour # Determine current hour
t = datetime.today() t = datetime.today()
@ -476,15 +496,6 @@ def main():
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'])
# Mark children for action
if args.recurring is True:
for child_item in child_items_all:
child_item['r_tag'] = 1
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(
@ -516,6 +527,7 @@ def main():
if label_id is not None: if label_id is not None:
# Skip processing an item if it has already been checked # Skip processing an item if it has already been checked
if item['checked'] == 1: if item['checked'] == 1:
#TODO: remove label if it has it?
continue continue
# Check item type # Check item type
@ -524,7 +536,7 @@ def main():
logging.debug('Identified \'%s\' as %s type', logging.debug('Identified \'%s\' as %s type',
item['content'], item_type) item['content'], item_type)
# If there is no item of section type # If there is no item //TODO: or section type
if item_type is None: if item_type is None:
# Handle parentless tasks # Handle parentless tasks
if item['parent_id'] == 0: if item['parent_id'] == 0: