Add missing code
This commit is contained in:
		
							parent
							
								
									ac456ce5be
								
							
						
					
					
						commit
						5c51751111
					
				
							
								
								
									
										24
									
								
								agenda/accommodation.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								agenda/accommodation.py
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,24 @@
 | 
				
			||||||
 | 
					"""Accomodation"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import yaml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from .types import Event
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def get_events(filepath: str) -> list[Event]:
 | 
				
			||||||
 | 
					    """Get accomodation from YAML."""
 | 
				
			||||||
 | 
					    with open(filepath) as f:
 | 
				
			||||||
 | 
					        return [
 | 
				
			||||||
 | 
					            Event(
 | 
				
			||||||
 | 
					                date=item["from"],
 | 
				
			||||||
 | 
					                end_date=item["to"],
 | 
				
			||||||
 | 
					                name="accommodation",
 | 
				
			||||||
 | 
					                title=(
 | 
				
			||||||
 | 
					                    f'{item["location"]} Airbnb'
 | 
				
			||||||
 | 
					                    if item["operator"] == "airbnb"
 | 
				
			||||||
 | 
					                    else item["name"]
 | 
				
			||||||
 | 
					                ),
 | 
				
			||||||
 | 
					                url=item.get("url"),
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					            for item in yaml.safe_load(f)
 | 
				
			||||||
 | 
					        ]
 | 
				
			||||||
		Loading…
	
		Reference in a new issue