v.0.7.1 reorganize classes dir

This commit is contained in:
tiijay
2025-11-13 19:54:51 +01:00
parent 303a0f4468
commit 3351dfd1b0
7 changed files with 55 additions and 57 deletions

View File

@@ -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 .location import Location
from .response_status import ResponseStatus from .response_status import ResponseStatus
from .weather_response import WeatherResponse from .weather_response import WeatherResponse
from .weather import Weather
__all__ = ["Weather", __all__ = ["Weather", "AirQuality","Condition","CurrentCondition","Location", "ResponseStatus","WeatherResponse"]
"AirQuality","Condition","CurrentCondition","Location",
"ResponseStatus","WeatherResponse"]

View 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
View 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})'

View 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})'

View File

@@ -1,55 +1,5 @@
from .location import Location from .location import Location
from .current_condition import CurrentCondition
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: class Weather:
def __init__(self, location: Location, current: CurrentCondition): def __init__(self, location: Location, current: CurrentCondition):
self.location = location self.location = location

View File

@@ -1,5 +1,5 @@
from app.classes import Weather from .weather import Weather
from app.classes import ResponseStatus from .response_status import ResponseStatus
class WeatherResponse: class WeatherResponse:
_response_status: ResponseStatus _response_status: ResponseStatus

View File

@@ -1,4 +1,5 @@
from .font_checker import Font_Checker from .font_checker import Font_Checker
from .weather_checker import Weather_Checker from .weather_checker import Weather_Checker
from .emoji_checker import Emoji_Checker from .emoji_checker import Emoji_Checker
__all__ = [ 'Font_Checker', 'Weather_Checker', 'Emoji_Checker'] __all__ = [ 'Font_Checker', 'Weather_Checker', 'Emoji_Checker']