Type indication now seems to work on all levels

pull/30/head
Hoffelhas 2023-01-08 15:28:58 +01:00
parent 86eb720f50
commit a589c159c0
1 changed files with 28 additions and 11 deletions

View File

@ -440,7 +440,7 @@ def get_all_data(self, api):
return data return data
# Assign current type based on settings # Find the type based on name suffix.
def check_name(args, string, num): def check_name(args, string, num):
@ -469,6 +469,13 @@ def check_name(args, string, num):
current_type += 's' current_type += 's'
elif s == args.p_suffix: elif s == args.p_suffix:
current_type += 'p' current_type += 'p'
# Always return a three letter string
if len(current_type) == 2:
current_type = 'x' + current_type
elif len(current_type) == 1:
current_type = 'xx' + current_type
except: except:
logging.debug("String {} not recognised.".format(string)) logging.debug("String {} not recognised.".format(string))
current_type = None current_type = None
@ -1020,7 +1027,7 @@ def autodoist_magic(args, api, connection):
# Parentless task has no type, so skip any children. # Parentless task has no type, so skip any children.
continue continue
else: else:
if hierarchy_boolean[1]: if hierarchy_boolean[0]:
# Inherit task type # Inherit task type
dominant_type = task_type dominant_type = task_type
elif hierarchy_boolean[1]: elif hierarchy_boolean[1]:
@ -1030,8 +1037,7 @@ def autodoist_magic(args, api, connection):
# Inherit project type # Inherit project type
dominant_type = project_type dominant_type = project_type
# for ind, char in enumerate(dominant_type): # If indicated on project level
if dominant_type[0] == 's': if dominant_type[0] == 's':
if not first_found[0]: if not first_found[0]:
@ -1051,6 +1057,22 @@ def autodoist_magic(args, api, connection):
elif dominant_type[1] == 'p': elif dominant_type[1] == 'p':
add_label(connection, task, dominant_type, next_action_label, overview_task_ids, overview_task_labels) add_label(connection, task, dominant_type, next_action_label, overview_task_ids, overview_task_labels)
# If indicated on section level
if dominant_type[0] == 'x' and dominant_type[1] == 's':
if not first_found[1]:
add_label(connection, task, dominant_type, next_action_label, overview_task_ids, overview_task_labels)
elif dominant_type[0] == 'x' and dominant_type[1] == 'p':
add_label(connection, task, dominant_type, next_action_label, overview_task_ids, overview_task_labels)
# If indicated on parentless task level
if dominant_type[1] == 'x' and dominant_type[2] == 's':
if not first_found[1]:
add_label(connection, task, dominant_type, next_action_label, overview_task_ids, overview_task_labels)
elif dominant_type[1] == 'x' and dominant_type[2] == 'p':
add_label(connection, task, dominant_type, next_action_label, overview_task_ids, overview_task_labels)
# If a parentless or sub-task which has children # If a parentless or sub-task which has children
if len(child_tasks) > 0: if len(child_tasks) > 0:
@ -1064,10 +1086,10 @@ def autodoist_magic(args, api, connection):
if task.parent_id != 0 and dominant_type == None: if task.parent_id != 0 and dominant_type == None:
dominant_type = task_type dominant_type = task_type
# Only last character is relevant # Only last character is relevant for subtasks
dominant_type = dominant_type[-1] dominant_type = dominant_type[-1]
# Process sequential tagged tasks (task_type can overrule project_type) # Process sequential tagged tasks
if dominant_type == 's': if dominant_type == 's':
for child_task in child_tasks: for child_task in child_tasks:
@ -1086,13 +1108,8 @@ def autodoist_magic(args, api, connection):
connection, child_task, dominant_type, next_action_label, overview_task_ids, overview_task_labels) connection, child_task, dominant_type, next_action_label, overview_task_ids, overview_task_labels)
remove_label( remove_label(
task, next_action_label, overview_task_ids, overview_task_labels) task, next_action_label, overview_task_ids, overview_task_labels)
# else: #TODO: is this still needed?
# # Clean for good measure
# remove_label(
# child_task, next_action_label, overview_task_ids, overview_task_labels)
# Process parallel tagged tasks or untagged parents # Process parallel tagged tasks or untagged parents
# elif dominant_type == 'parallel' or (dominant_type == 's-p' and next_action_label in task.labels):
elif dominant_type == 'p' and next_action_label in task.labels: elif dominant_type == 'p' and next_action_label in task.labels:
remove_label( remove_label(
task, next_action_label, overview_task_ids, overview_task_labels) task, next_action_label, overview_task_ids, overview_task_labels)