From cdb5799313a314e9541db6505efba6dcade1d6eb Mon Sep 17 00:00:00 2001 From: Alex Kelly Date: Mon, 23 Aug 2021 17:10:17 -0400 Subject: [PATCH] fix: corrected the issue causing split project entries closes #1 --- task_status/task_status.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/task_status/task_status.py b/task_status/task_status.py index ef30925..b58e7ab 100755 --- a/task_status/task_status.py +++ b/task_status/task_status.py @@ -2,11 +2,11 @@ """ Get completed tasks from taskwarrior and output a simple report """ import subprocess import json +import itertools +import operator from datetime import date from dateutil.relativedelta import relativedelta, MO import click -import itertools -import operator __version__ = "0.2.0" @@ -35,16 +35,20 @@ def main(uuid, header): entries = json.loads(tasks.stdout.decode()) output_list = [] + project_list = [] if header: print(f"Reporting from: {last_monday}") - for i, g in itertools.groupby(entries, key=operator.itemgetter("project")): - output_list.append(list(g)) - for project in output_list: - print(f'* {project[0]["project"]}') - for entry in project: - if uuid: + for status_projects, status_entries in itertools.groupby( + entries, key=operator.itemgetter("project") + ): + project_list.append(status_projects) + output_list.append(list(status_entries)) + for project in project_list: + print(f"* {project}") + for entry in entries: + if entry["project"] == project and uuid: print(f'\t* {entry["description"]} ({entry["uuid"]})') - else: + if entry["project"] == project: print(f'\t* {entry["description"]}')