fix: correct issue with tasks that have no project

Create a function that validates tasks have a project assigned.  If the
project attribute is missing, add "none"

Closes #1
This commit is contained in:
Alex Kelly 2023-01-31 11:47:17 -05:00
parent c1d021ccaf
commit cd1fc35f4c

View file

@ -10,6 +10,14 @@ import click
__version__ = "0.3.0" __version__ = "0.3.0"
def validate_tasks(tasks):
""" Validate tasks have a proejct, inject "None" if they don't """
try:
for task in tasks:
test = task["project"]
except KeyError:
task["project"] = "None"
return tasks
@click.command() @click.command()
@click.version_option(__version__, prog_name="task-status") @click.version_option(__version__, prog_name="task-status")
@ -30,6 +38,7 @@ def main(uuid, header, bullet, sort):
"status_report:display", "status_report:display",
"-home", "-home",
"-DELETED", "-DELETED",
"-delegated",
"export", "export",
] ]
tasks = subprocess.run( tasks = subprocess.run(
@ -37,8 +46,7 @@ def main(uuid, header, bullet, sort):
capture_output=True, capture_output=True,
check=True, check=True,
) )
entries = validate_tasks(json.loads(tasks.stdout.decode()))
entries = json.loads(tasks.stdout.decode())
output_list = [] output_list = []
project_list = [] project_list = []
if header: if header: