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:
		
					parent
					
						
							
								c1d021ccaf
							
						
					
				
			
			
				commit
				
					
						cd1fc35f4c
					
				
			
		
					 1 changed files with 10 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -10,6 +10,14 @@ import click
 | 
			
		|||
 | 
			
		||||
__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.version_option(__version__, prog_name="task-status")
 | 
			
		||||
| 
						 | 
				
			
			@ -30,6 +38,7 @@ def main(uuid, header, bullet, sort):
 | 
			
		|||
        "status_report:display",
 | 
			
		||||
        "-home",
 | 
			
		||||
        "-DELETED",
 | 
			
		||||
        "-delegated",
 | 
			
		||||
        "export",
 | 
			
		||||
    ]
 | 
			
		||||
    tasks = subprocess.run(
 | 
			
		||||
| 
						 | 
				
			
			@ -37,8 +46,7 @@ def main(uuid, header, bullet, sort):
 | 
			
		|||
        capture_output=True,
 | 
			
		||||
        check=True,
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    entries = json.loads(tasks.stdout.decode())
 | 
			
		||||
    entries = validate_tasks(json.loads(tasks.stdout.decode()))
 | 
			
		||||
    output_list = []
 | 
			
		||||
    project_list = []
 | 
			
		||||
    if header:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue