forked from mirrors/autodoist
Pseudocode updated, section loop build-in, still need to build a class to handle 'no section' tasks, and finalize labeling logic
parent
a913c74086
commit
3943c5c614
40
autodoist.py
40
autodoist.py
|
@ -128,7 +128,7 @@ def main():
|
|||
"\n\nNo API key set. Run Autodoist with '-a <YOUR_API_KEY>'\n")
|
||||
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 < 1 or args.end > 24:
|
||||
logging.error(
|
||||
|
@ -374,10 +374,20 @@ def main():
|
|||
project['name'], project_type)
|
||||
|
||||
# Get all items for the project
|
||||
items = api.items.all(
|
||||
lambda x: x['project_id'] == project['id'])
|
||||
# items = api.items.all(
|
||||
# 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
|
||||
for item in items:
|
||||
|
@ -434,6 +444,16 @@ def main():
|
|||
# Check if the T0 task date has changed
|
||||
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:
|
||||
# Determine current hour
|
||||
t = datetime.today()
|
||||
|
@ -476,15 +496,6 @@ def main():
|
|||
item.update(due=item_due)
|
||||
# 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:
|
||||
# If date has never been saved before, create a new entry
|
||||
logging.debug(
|
||||
|
@ -516,6 +527,7 @@ def main():
|
|||
if label_id is not None:
|
||||
# Skip processing an item if it has already been checked
|
||||
if item['checked'] == 1:
|
||||
#TODO: remove label if it has it?
|
||||
continue
|
||||
|
||||
# Check item type
|
||||
|
@ -524,7 +536,7 @@ def main():
|
|||
logging.debug('Identified \'%s\' as %s 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:
|
||||
# Handle parentless tasks
|
||||
if item['parent_id'] == 0:
|
||||
|
|
Loading…
Reference in New Issue