from __future__ import annotations from os import environ from gibil.classes.env_loader import EnvLoader from gibil.classes.weather_sample_data import WeatherSampleData from gibil.classes.weather_store import WeatherStore, WeatherStoreConfigurationError from gibil.classes.weather_display import WeatherDisplay class WebUI: """Composes Astrape web modules into one page.""" def __init__(self) -> None: self.weather_display = WeatherDisplay() def render_page(self) -> str: return f""" Astrape

Astrape

Gibil web UI

{self.weather_display.render()}
""" def weather_payload(self) -> str: EnvLoader().load() if environ.get("ASTRAPE_WEB_SAMPLE_DATA") == "1": return self.weather_display.data_payload(WeatherSampleData().build()) try: dataset = WeatherStore.from_env().load_display_dataset() except WeatherStoreConfigurationError: dataset = None return self.weather_display.data_payload(dataset)