first save
This commit is contained in:
0
app/classes/__init__.py
Normal file
0
app/classes/__init__.py
Normal file
9
app/classes/location.py
Normal file
9
app/classes/location.py
Normal file
@@ -0,0 +1,9 @@
|
||||
class Location:
|
||||
def __init__(self, **kwargs):
|
||||
self.name = kwargs.get('name', '')
|
||||
self.region = kwargs.get('region', '')
|
||||
self.country = kwargs.get('country', '')
|
||||
self.localtime = kwargs.get('localtime', '')
|
||||
|
||||
def __repr__(self):
|
||||
return f"Location(name='{self.name}', region='{self.region}', country='{self.country}')"
|
||||
59
app/classes/weather.py
Normal file
59
app/classes/weather.py
Normal file
@@ -0,0 +1,59 @@
|
||||
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}'
|
||||
Reference in New Issue
Block a user