60 lines
1.8 KiB
Python
60 lines
1.8 KiB
Python
from .location import Location
|
|
|
|
|
|
class Condition:
|
|
def __init__(self, **kwargs):
|
|
self.text = kwargs.get('text')
|
|
self.icon = kwargs.get('icon')
|
|
|
|
def __repr__(self):
|
|
return f'Condition(text={self.text}, icon={self.icon})'
|
|
|
|
|
|
class AirQuality:
|
|
def __init__(self, **kwargs):
|
|
# Required pollutants
|
|
self.co = float(kwargs.get('co', 0))
|
|
self.no2 = float(kwargs.get('no2', 0))
|
|
self.o3 = float(kwargs.get('o3', 0))
|
|
self.so2 = float(kwargs.get('so2', 0))
|
|
self.pm2_5 = float(kwargs.get('pm2_5'))
|
|
self.pm10 = float(kwargs.get('pm10', 0))
|
|
# Air quality indices
|
|
self.us_epa_index = int(kwargs.get('us-epa-index', 0))
|
|
self.gb_defra_index = int(kwargs.get('gb-defra-index', 0))
|
|
|
|
def __repr__(self):
|
|
return f'AirQuality(CO={self.co}, NO2={self.no2}, O3={self.o3}, PM2.5={self.pm2_5})'
|
|
|
|
|
|
class CurrentCondition:
|
|
def __init__(
|
|
self,
|
|
# condition,
|
|
# air_quality,
|
|
**kwargs,
|
|
):
|
|
self.last_updated = kwargs.get('last_updated', '')
|
|
self.temp_c = float(kwargs.get('temp_c', 0))
|
|
self.is_day = int(kwargs.get('is_day', 0))
|
|
self.condition = Condition(**kwargs.get('condition'))
|
|
self.wind_kph = float(kwargs.get('wind_kph', 0))
|
|
self.wind_dir = kwargs.get('wind_dir', '')
|
|
self.pressure_mb = float(kwargs.get('pressure_mb', 0))
|
|
self.humidity = int(kwargs.get('humidity', 0))
|
|
self.cloud = int(kwargs.get('cloud', 0))
|
|
self.feelslike_c = float(kwargs.get('feelslike_c', 0))
|
|
self.air_quality = AirQuality(**kwargs.get('air_quality'))
|
|
|
|
def __repr__(self):
|
|
return f'CurrentCondition(condition={self.condition}, air_quality={self.air_quality}, last_updated={self.last_updated}, temp_c={self.temp_c}, wind_dir={self.wind_dir}, wind_kph={self.wind_kph})'
|
|
|
|
|
|
class Weather:
|
|
def __init__(self, location, current):
|
|
self.location = location
|
|
self.current = current
|
|
|
|
def __repr__(self):
|
|
return f'Weather(condition={self.location}, current={self.current}'
|