Skip to content

Commit 0aa81fb

Browse files
authored
Fix parse weather forecast data (#68)
* fix skipped weather forecast data in parsing * bump version to v3.0.1 * update weather enums
1 parent 30d3a9d commit 0aa81fb

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "PyBMKG"
3-
version = "3.0.0"
3+
version = "3.0.1"
44
description = "Python BMKG API Wrapper"
55
authors = ["Kira <kiraware@github.com>"]
66
maintainers = ["Kira <kiraware@github.com>", "vexra <vexra@github.com>"]

src/bmkg/enums/weather.py

+14-19
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ class Weather(IntEnum):
1313
1414
Attributes:
1515
CLEAR_SKIES: `0`
16-
PARTLY_CLOUDY: `1`
17-
PARTLY_CLOUDY2: `2`
16+
SUNNY: `1`
17+
PARTLY_CLOUDY: `2`
1818
MOSTLY_CLOUDY: `3`
1919
OVERCAST: `4`
2020
HAZE: `5`
2121
SMOKE: `10`
22+
THUNDER: `17`
2223
FOG: `45`
23-
LIGHT_RAIN: `60`
24-
RAIN: `61`
25-
HEAVY_RAIN: `63`
24+
LIGHT_RAIN: `61`
25+
MODERATE_RAIN: `63`
2626
ISOLATED_SHOWER: `80`
27-
SEVERE_THUNDERSTORM: `95`
28-
SEVERE_THUNDERSTORM2: `97`
27+
THUNDERSTORM: `95`
28+
SEVERE_THUNDERSTORM: `97`
2929
3030
Examples:
3131
>>> Weather(0)
@@ -38,24 +38,19 @@ class Weather(IntEnum):
3838
True
3939
>>> print(Weather.CLEAR_SKIES)
4040
0
41-
42-
Note:
43-
There is `PARTLY_CLOUDY` and `PARTLY_CLOUDY2`, the weather
44-
condition is equal only the number representation is different. This is
45-
also hold true for `SEVERE_THUNDERSTORM` and `SEVERE_THUNDERSTORM2`.
4641
"""
4742

4843
CLEAR_SKIES: int = 0
49-
PARTLY_CLOUDY: int = 1
50-
PARTLY_CLOUDY2: int = 2
44+
SUNNY: int = 1
45+
PARTLY_CLOUDY: int = 2
5146
MOSTLY_CLOUDY: int = 3
5247
OVERCAST: int = 4
5348
HAZE: int = 5
5449
SMOKE: int = 10
50+
THUNDER: int = 17
5551
FOG: int = 45
56-
LIGHT_RAIN: int = 60
57-
RAIN: int = 61
58-
HEAVY_RAIN: int = 63
52+
LIGHT_RAIN: int = 61
53+
MODERATE_RAIN: int = 63
5954
ISOLATED_SHOWER: int = 80
60-
SEVERE_THUNDERSTORM: int = 95
61-
SEVERE_THUNDERSTORM2: int = 97
55+
THUNDERSTORM: int = 95
56+
SEVERE_THUNDERSTORM: int = 97

src/bmkg/parsers/parse_weather_forecast_data.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ def parse_weather_forecast_data(
2121
location = parse_location_data(weather_forecast_data["lokasi"])
2222
weathers = [
2323
parse_weather_data(weather)
24-
for weather in weather_forecast_data["data"][0]["cuaca"][0]
24+
for weathers in weather_forecast_data["data"][0]["cuaca"]
25+
for weather in weathers
2526
]
2627

2728
return WeatherForecast(location, weathers)

0 commit comments

Comments
 (0)