It would be nice if tasks with multiple parents (i.e., parents with parents) could be displayed with the correct indentation. I've implemented this using a nasty hack for up to three levels of indentation; it should be possible to make a recursive function to replace what I've written, which would allow any amount of indentation.
Here's my attempt, with each level of recursion manually written:
def tasks(listID):
tasks = service.tasks().list(tasklist=listID).execute()
try:
for task in tasks['items']:
if task['title'] == '': pass
else:
taskName=task['title']
if 'parent' in task.keys():
for maybeParent in tasks['items']:
if maybeParent['title'] == '': pass
else:
if maybeParent['id'] == task['parent']:
if 'parent' in maybeParent.keys():
for maybeParentsParent in tasks['items']:
if maybeParentsParent['title'] == '': pass
else:
if maybeParentsParent['id'] == maybeParent['parent']:
if 'parent' in maybeParentsParent.keys():
print ' '+'• '+task['title'].encode('utf-8')
break
else:
print ' '+'• '+task['title'].encode('utf-8')
break
else:
print ' '+'• '+task['title'].encode('utf-8')
break
else:
print '• '+task['title'].encode('utf-8')
except KeyError: print ' No tasks.'
It would be nice if tasks with multiple parents (i.e., parents with parents) could be displayed with the correct indentation. I've implemented this using a nasty hack for up to three levels of indentation; it should be possible to make a recursive function to replace what I've written, which would allow any amount of indentation.
Here's my attempt, with each level of recursion manually written: