Minor bugfixes in serial and parallel logic

master
Hoffelhas 2020-03-30 16:08:52 +02:00
parent a4fd835474
commit 347e0afcf1
1 changed files with 19 additions and 7 deletions

View File

@ -33,6 +33,8 @@ def main():
log_level = logging.INFO
logging.basicConfig(level=log_level)
args.api_key = "18fa3286dd8f7c4fefe8655f8732a235b4ed7fb0"
# Check we have a API key
if not args.api_key:
logging.error('No API key set, exiting...')
@ -134,6 +136,8 @@ def main():
else:
for project in api.projects.all():
print(project['name'])
# Get project type
project_type, project_type_changed = get_project_type(project)
logging.debug('Project \'%s\' being processed as %s', project['name'], project_type)
@ -158,6 +162,12 @@ def main():
for item in items:
# Skip processing an item if it has already been checked
if item['checked'] == 1:
continue
print(item['content'])
# Check item type
item_type, item_type_changed = get_item_type(item, project_type)
logging.debug('Identified \'%s\' as %s type', item['content'], item_type)
@ -194,29 +204,31 @@ def main():
# If there are children, label them instead
if len(child_items) > 0:
child_first_found = False
# Check if state has changed, if so clean for good measure
if item_type_changed == 1:
[remove_label(item, label_id) for child_item in child_items]
[remove_label(child_item, label_id) for child_item in child_items]
# Process serial tagged items
if item_type == 'serial':
child_first_found = False
for child_item in child_items:
if child_item['checked'] == 0 and not child_first_found and label_id in item['labels']:
child_first_found = True
add_label(child_item, label_id)
child_item['parent_type'] = item_type
child_first_found = True
else:
remove_label(child_item, label_id)
# Process parallel tagged items or untagged parents
elif item_type == 'parallel':
for child_item in child_items:
if child_item['checked'] == 0:
child_first_found = True
add_label(child_item, label_id)
child_item['parent_type'] = item_type
# Remove the label from the parent
if item_type:
if item_type and child_first_found:
remove_label(item, label_id)
# If item is too far in the future, remove the next_action tag and skip