python-google-weather-api 0.0.5__tar.gz → 0.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (16) hide show
  1. {python_google_weather_api-0.0.5/src/python_google_weather_api.egg-info → python_google_weather_api-0.0.6}/PKG-INFO +1 -1
  2. {python_google_weather_api-0.0.5 → python_google_weather_api-0.0.6}/pyproject.toml +1 -1
  3. {python_google_weather_api-0.0.5 → python_google_weather_api-0.0.6}/src/google_weather_api/api.py +12 -2
  4. {python_google_weather_api-0.0.5 → python_google_weather_api-0.0.6/src/python_google_weather_api.egg-info}/PKG-INFO +1 -1
  5. {python_google_weather_api-0.0.5 → python_google_weather_api-0.0.6}/LICENSE +0 -0
  6. {python_google_weather_api-0.0.5 → python_google_weather_api-0.0.6}/README.md +0 -0
  7. {python_google_weather_api-0.0.5 → python_google_weather_api-0.0.6}/setup.cfg +0 -0
  8. {python_google_weather_api-0.0.5 → python_google_weather_api-0.0.6}/src/google_weather_api/__init__.py +0 -0
  9. {python_google_weather_api-0.0.5 → python_google_weather_api-0.0.6}/src/google_weather_api/exceptions.py +0 -0
  10. {python_google_weather_api-0.0.5 → python_google_weather_api-0.0.6}/src/google_weather_api/model.py +0 -0
  11. {python_google_weather_api-0.0.5 → python_google_weather_api-0.0.6}/src/google_weather_api/py.typed +0 -0
  12. {python_google_weather_api-0.0.5 → python_google_weather_api-0.0.6}/src/python_google_weather_api.egg-info/SOURCES.txt +0 -0
  13. {python_google_weather_api-0.0.5 → python_google_weather_api-0.0.6}/src/python_google_weather_api.egg-info/dependency_links.txt +0 -0
  14. {python_google_weather_api-0.0.5 → python_google_weather_api-0.0.6}/src/python_google_weather_api.egg-info/requires.txt +0 -0
  15. {python_google_weather_api-0.0.5 → python_google_weather_api-0.0.6}/src/python_google_weather_api.egg-info/top_level.txt +0 -0
  16. {python_google_weather_api-0.0.5 → python_google_weather_api-0.0.6}/tests/test_api.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-google-weather-api
3
- Version: 0.0.5
3
+ Version: 0.0.6
4
4
  Summary: A python client library for Google Weather API
5
5
  Author-email: tronikos <tronikos@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-google-weather-api"
3
- version = "0.0.5"
3
+ version = "0.0.6"
4
4
  license = "Apache-2.0"
5
5
  authors = [
6
6
  { name="tronikos", email="tronikos@gmail.com" },
@@ -68,9 +68,19 @@ class GoogleWeatherApi:
68
68
  res: dict[str, Any] = await resp.json()
69
69
  _LOGGER.debug("Got %s for %s", resp.status, url)
70
70
  if resp.status != HTTPStatus.OK:
71
+ error_data = res.get("error", {})
72
+ error_msg = error_data.get("message", "Unknown API error")
73
+
71
74
  if resp.status in (HTTPStatus.UNAUTHORIZED, HTTPStatus.FORBIDDEN):
72
- raise GoogleWeatherApiAuthError(res["error"]["message"])
73
- raise GoogleWeatherApiResponseError(res["error"]["message"])
75
+ raise GoogleWeatherApiAuthError(error_msg)
76
+
77
+ # Google APIs often return 400 Bad Request for invalid API keys
78
+ if resp.status == HTTPStatus.BAD_REQUEST:
79
+ for detail in error_data.get("details", []):
80
+ if detail.get("reason") == "API_KEY_INVALID":
81
+ raise GoogleWeatherApiAuthError(error_msg)
82
+
83
+ raise GoogleWeatherApiResponseError(error_msg)
74
84
  return res
75
85
  except TimeoutError as err:
76
86
  raise GoogleWeatherApiConnectionError("Timeout") from err
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-google-weather-api
3
- Version: 0.0.5
3
+ Version: 0.0.6
4
4
  Summary: A python client library for Google Weather API
5
5
  Author-email: tronikos <tronikos@gmail.com>
6
6
  License-Expression: Apache-2.0