Handle launch["net_precision"] == None
This commit is contained in:
		
							parent
							
								
									afd538d362
								
							
						
					
					
						commit
						b654e75cf5
					
				| 
						 | 
					@ -57,7 +57,7 @@ def format_time(time_str: str, net_precision: str) -> tuple[str, str | None]:
 | 
				
			||||||
        case "Second":
 | 
					        case "Second":
 | 
				
			||||||
            time_format = "%d %b %Y"
 | 
					            time_format = "%d %b %Y"
 | 
				
			||||||
            include_time = True
 | 
					            include_time = True
 | 
				
			||||||
        case _ if net_precision.startswith("Quarter "):
 | 
					        case _ if net_precision and net_precision.startswith("Quarter "):
 | 
				
			||||||
            time_format = f"Q{net_precision[-1]} %Y"
 | 
					            time_format = f"Q{net_precision[-1]} %Y"
 | 
				
			||||||
        case _:
 | 
					        case _:
 | 
				
			||||||
            time_format = None
 | 
					            time_format = None
 | 
				
			||||||
| 
						 | 
					@ -89,13 +89,18 @@ def summarize_launch(launch: Launch) -> Summary:
 | 
				
			||||||
    launch_provider = launch["launch_service_provider"]["name"]
 | 
					    launch_provider = launch["launch_service_provider"]["name"]
 | 
				
			||||||
    launch_provider_abbrev = launch_providers.get(launch_provider)
 | 
					    launch_provider_abbrev = launch_providers.get(launch_provider)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    t0_date, t0_time = format_time(launch["net"], launch["net_precision"]["name"])
 | 
					    try:
 | 
				
			||||||
 | 
					        net_precision = launch["net_precision"]["name"]
 | 
				
			||||||
 | 
					    except (TypeError, IndexError):
 | 
				
			||||||
 | 
					        net_precision = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    t0_date, t0_time = format_time(launch["net"], net_precision)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
        "name": launch["name"],
 | 
					        "name": launch["name"],
 | 
				
			||||||
        "status": launch["status"],
 | 
					        "status": launch["status"],
 | 
				
			||||||
        "net": launch["net"],
 | 
					        "net": launch["net"],
 | 
				
			||||||
        "net_precision": launch["net_precision"]["name"],
 | 
					        "net_precision": net_precision,
 | 
				
			||||||
        "t0_date": t0_date,
 | 
					        "t0_date": t0_date,
 | 
				
			||||||
        "t0_time": t0_time,
 | 
					        "t0_time": t0_time,
 | 
				
			||||||
        "window_start": launch["window_start"],
 | 
					        "window_start": launch["window_start"],
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue