parent
							
								
									1453c4015c
								
							
						
					
					
						commit
						7456f72325
					
				
							
								
								
									
										31
									
								
								update_bristol_bins.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										31
									
								
								update_bristol_bins.py
									
									
									
									
									
										Executable file
									
								
							| 
						 | 
					@ -0,0 +1,31 @@
 | 
				
			||||||
 | 
					#!/usr/bin/python3
 | 
				
			||||||
 | 
					"""Update waste schedule from Bristol City Council."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import asyncio
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
 | 
					from datetime import date
 | 
				
			||||||
 | 
					from time import time
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import agenda.types
 | 
				
			||||||
 | 
					import agenda.waste_schedule
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					config = __import__("config.default", fromlist=[""])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async def bristol_waste_collection_events() -> list[agenda.types.Event]:
 | 
				
			||||||
 | 
					    """Waste colllection events."""
 | 
				
			||||||
 | 
					    uprn = "358335"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return await agenda.waste_schedule.get_bristol_gov_uk(
 | 
				
			||||||
 | 
					        date.today(), config.DATA_DIR, uprn, refresh=True
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					today = date.today()
 | 
				
			||||||
 | 
					t0 = time()
 | 
				
			||||||
 | 
					events = asyncio.run(bristol_waste_collection_events())
 | 
				
			||||||
 | 
					time_taken = time() - t0
 | 
				
			||||||
 | 
					if sys.stdin.isatty():
 | 
				
			||||||
 | 
					    for event in events:
 | 
				
			||||||
 | 
					        print(event)
 | 
				
			||||||
 | 
					    print(f"took {time_taken:.1f} seconds")
 | 
				
			||||||
		Loading…
	
		Reference in a new issue