v.0.7.1 reorganize classes dir
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
from .weather import Weather, AirQuality, Condition, CurrentCondition
|
||||
from .current_condition import CurrentCondition
|
||||
from .air_quality import AirQuality
|
||||
from .condition import Condition
|
||||
from .location import Location
|
||||
from .response_status import ResponseStatus
|
||||
from .weather_response import WeatherResponse
|
||||
from .weather import Weather
|
||||
|
||||
__all__ = ["Weather",
|
||||
"AirQuality","Condition","CurrentCondition","Location",
|
||||
"ResponseStatus","WeatherResponse"]
|
||||
__all__ = ["Weather", "AirQuality","Condition","CurrentCondition","Location", "ResponseStatus","WeatherResponse"]
|
||||
15
app/classes/air_quality.py
Normal file
15
app/classes/air_quality.py
Normal file
@@ -0,0 +1,15 @@
|
||||
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})'
|
||||
7
app/classes/condition.py
Normal file
7
app/classes/condition.py
Normal file
@@ -0,0 +1,7 @@
|
||||
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})'
|
||||
24
app/classes/current_condition.py
Normal file
24
app/classes/current_condition.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from .condition import Condition
|
||||
from .air_quality import AirQuality
|
||||
|
||||
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})'
|
||||
@@ -1,55 +1,5 @@
|
||||
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})'
|
||||
|
||||
|
||||
from .current_condition import CurrentCondition
|
||||
class Weather:
|
||||
def __init__(self, location: Location, current: CurrentCondition):
|
||||
self.location = location
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from app.classes import Weather
|
||||
from app.classes import ResponseStatus
|
||||
from .weather import Weather
|
||||
from .response_status import ResponseStatus
|
||||
|
||||
class WeatherResponse:
|
||||
_response_status: ResponseStatus
|
||||
|
||||
Reference in New Issue
Block a user