Skip to content

Commit

Permalink
Fix parse weather forecast data (#68)
Browse files Browse the repository at this point in the history
* fix skipped weather forecast data in parsing
* bump version to v3.0.1
* update weather enums
  • Loading branch information
kiraware authored Jan 2, 2025
1 parent 30d3a9d commit 0aa81fb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "PyBMKG"
version = "3.0.0"
version = "3.0.1"
description = "Python BMKG API Wrapper"
authors = ["Kira <[email protected]>"]
maintainers = ["Kira <[email protected]>", "vexra <[email protected]>"]
Expand Down
33 changes: 14 additions & 19 deletions src/bmkg/enums/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ class Weather(IntEnum):
Attributes:
CLEAR_SKIES: `0`
PARTLY_CLOUDY: `1`
PARTLY_CLOUDY2: `2`
SUNNY: `1`
PARTLY_CLOUDY: `2`
MOSTLY_CLOUDY: `3`
OVERCAST: `4`
HAZE: `5`
SMOKE: `10`
THUNDER: `17`
FOG: `45`
LIGHT_RAIN: `60`
RAIN: `61`
HEAVY_RAIN: `63`
LIGHT_RAIN: `61`
MODERATE_RAIN: `63`
ISOLATED_SHOWER: `80`
SEVERE_THUNDERSTORM: `95`
SEVERE_THUNDERSTORM2: `97`
THUNDERSTORM: `95`
SEVERE_THUNDERSTORM: `97`
Examples:
>>> Weather(0)
Expand All @@ -38,24 +38,19 @@ class Weather(IntEnum):
True
>>> print(Weather.CLEAR_SKIES)
0
Note:
There is `PARTLY_CLOUDY` and `PARTLY_CLOUDY2`, the weather
condition is equal only the number representation is different. This is
also hold true for `SEVERE_THUNDERSTORM` and `SEVERE_THUNDERSTORM2`.
"""

CLEAR_SKIES: int = 0
PARTLY_CLOUDY: int = 1
PARTLY_CLOUDY2: int = 2
SUNNY: int = 1
PARTLY_CLOUDY: int = 2
MOSTLY_CLOUDY: int = 3
OVERCAST: int = 4
HAZE: int = 5
SMOKE: int = 10
THUNDER: int = 17
FOG: int = 45
LIGHT_RAIN: int = 60
RAIN: int = 61
HEAVY_RAIN: int = 63
LIGHT_RAIN: int = 61
MODERATE_RAIN: int = 63
ISOLATED_SHOWER: int = 80
SEVERE_THUNDERSTORM: int = 95
SEVERE_THUNDERSTORM2: int = 97
THUNDERSTORM: int = 95
SEVERE_THUNDERSTORM: int = 97
3 changes: 2 additions & 1 deletion src/bmkg/parsers/parse_weather_forecast_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def parse_weather_forecast_data(
location = parse_location_data(weather_forecast_data["lokasi"])
weathers = [
parse_weather_data(weather)
for weather in weather_forecast_data["data"][0]["cuaca"][0]
for weathers in weather_forecast_data["data"][0]["cuaca"]
for weather in weathers
]

return WeatherForecast(location, weathers)

0 comments on commit 0aa81fb

Please sign in to comment.