mirror of https://github.com/Hoffelhas/autodoist
Implemented first iteration of asynchronous labelling of proejct/parentless tasks and sub-tasks
parent
50830eaaa8
commit
82b8bd2385
32
autodoist.py
32
autodoist.py
|
@ -44,9 +44,13 @@ def main():
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-d', '--delay', help='Specify the delay in seconds between syncs (default 5).', default=5, type=int)
|
'-d', '--delay', help='Specify the delay in seconds between syncs (default 5).', default=5, type=int)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-ps', '--p_suffix', help='Change suffix for parallel labeling (default "//").', default='//')
|
'-pp', '--pp_suffix', help='Change suffix for parallel-parallel labeling (default "//").', default='//')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-ss', '--s_suffix', help='Change suffix for sequential labeling (default "--").', default='--')
|
'-ss', '--ss_suffix', help='Change suffix for sequential-sequential labeling (default "--").', default='--')
|
||||||
|
parser.add_argument(
|
||||||
|
'-ps', '--ps_suffix', help='Change suffix for parallel-sequential labeling (default "/-").', default='/-')
|
||||||
|
parser.add_argument(
|
||||||
|
'-sp', '--sp_suffix', help='Change suffix for sequential-parallel labeling (default "-/").', default='-/')
|
||||||
parser.add_argument('-hf', '--hide_future', help='Skip labelling future tasks after the specified number of days (default 7).',
|
parser.add_argument('-hf', '--hide_future', help='Skip labelling future tasks after the specified number of days (default 7).',
|
||||||
default=7, type=int)
|
default=7, type=int)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
@ -220,7 +224,7 @@ def main():
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def get_type(object, key):
|
def get_type(object, key):
|
||||||
len_suffix = [len(args.p_suffix), len(args.s_suffix)]
|
len_suffix = [len(args.pp_suffix), len(args.ss_suffix), len(args.ps_suffix), len(args.sp_suffix)]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
old_type = object[key]
|
old_type = object[key]
|
||||||
|
@ -235,10 +239,14 @@ def main():
|
||||||
|
|
||||||
if name == 'Inbox':
|
if name == 'Inbox':
|
||||||
current_type = args.inbox
|
current_type = args.inbox
|
||||||
elif name[-len_suffix[0]:] == args.p_suffix:
|
elif name[-len_suffix[0]:] == args.pp_suffix:
|
||||||
current_type = 'parallel'
|
current_type = 'parallel'
|
||||||
elif name[-len_suffix[1]:] == args.s_suffix:
|
elif name[-len_suffix[1]:] == args.ss_suffix:
|
||||||
current_type = 'sequential'
|
current_type = 'sequential'
|
||||||
|
elif name[-len_suffix[1]:] == args.ps_suffix:
|
||||||
|
current_type = 'p-s'
|
||||||
|
elif name[-len_suffix[1]:] == args.sp_suffix:
|
||||||
|
current_type = 's-p'
|
||||||
else:
|
else:
|
||||||
current_type = None
|
current_type = None
|
||||||
|
|
||||||
|
@ -490,17 +498,17 @@ def main():
|
||||||
|
|
||||||
# If it is a parentless task
|
# If it is a parentless task
|
||||||
if item['parent_id'] == 0:
|
if item['parent_id'] == 0:
|
||||||
if project_type == 'sequential':
|
if project_type == 'sequential' or project_type == 's-p':
|
||||||
if not first_found_project:
|
if not first_found_project:
|
||||||
add_label(item, label_id)
|
add_label(item, label_id)
|
||||||
first_found_project = True
|
first_found_project = True
|
||||||
elif not first_found_item:
|
elif not first_found_item and not project_type == 's-p':
|
||||||
add_label(item, label_id)
|
add_label(item, label_id)
|
||||||
first_found_item = True
|
first_found_item = True
|
||||||
# else:
|
|
||||||
# remove_label(item, label_id)
|
elif project_type == 'parallel' or project_type == 'p-s':
|
||||||
elif project_type == 'parallel':
|
|
||||||
add_label(item, label_id)
|
add_label(item, label_id)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# If no project-type has been defined
|
# If no project-type has been defined
|
||||||
if item_type:
|
if item_type:
|
||||||
|
@ -514,7 +522,7 @@ def main():
|
||||||
for child_item in child_items]
|
for child_item in child_items]
|
||||||
|
|
||||||
# Process sequential tagged items (item_type can overrule project_type)
|
# Process sequential tagged items (item_type can overrule project_type)
|
||||||
if item_type == 'sequential':
|
if item_type == 'sequential' or item_type == 'p-s':
|
||||||
for child_item in child_items:
|
for child_item in child_items:
|
||||||
# Pass item_type down to the children
|
# Pass item_type down to the children
|
||||||
child_item['parent_type'] = item_type
|
child_item['parent_type'] = item_type
|
||||||
|
@ -527,7 +535,7 @@ def main():
|
||||||
remove_label(child_item, label_id)
|
remove_label(child_item, label_id)
|
||||||
|
|
||||||
# Process parallel tagged items or untagged parents
|
# Process parallel tagged items or untagged parents
|
||||||
elif item_type == 'parallel':
|
elif item_type == 'parallel' or (item_type == 's-p' and label_id in item['labels']):
|
||||||
remove_label(item, label_id)
|
remove_label(item, label_id)
|
||||||
for child_item in child_items:
|
for child_item in child_items:
|
||||||
child_item['parent_type'] = item_type
|
child_item['parent_type'] = item_type
|
||||||
|
|
Loading…
Reference in New Issue