meteocatpy 0.0.17 → 0.0.20
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.
- package/CHANGELOG.md +24 -0
- package/meteocatpy/data.py +27 -2
- package/meteocatpy/version.py +1 -1
- package/package.json +1 -1
- package/pyproject.toml +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
## [0.0.20](https://github.com/figorr/meteocatpy/compare/v0.0.19...v0.0.20) (2025-01-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* 0.0.20 ([8665c69](https://github.com/figorr/meteocatpy/commit/8665c696476d2a074673c4fc56d35aed61c68559))
|
|
7
|
+
* Update CHANGELOG.md ([495220e](https://github.com/figorr/meteocatpy/commit/495220ef4bc01393a1d1fc5506808ffceac9d80c))
|
|
8
|
+
|
|
9
|
+
## [0.0.19](https://github.com/figorr/meteocatpy/compare/v0.0.18...v0.0.19) (2025-01-08)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* 0.0.19 ([2884a6f](https://github.com/figorr/meteocatpy/commit/2884a6ff7216f412e5144ba8a89a300f6b0a42c2))
|
|
15
|
+
* fix timedelta ([dc716ad](https://github.com/figorr/meteocatpy/commit/dc716ad3843f1e138ccab6ac7e01d406e13cf4a5))
|
|
16
|
+
|
|
17
|
+
## [0.0.18](https://github.com/figorr/meteocatpy/compare/v0.0.17...v0.0.18) (2025-01-08)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* 0.0.18 ([bdc81d2](https://github.com/figorr/meteocatpy/commit/bdc81d2c4ada74478e66d376962bd2e7b01fe39b))
|
|
23
|
+
* fix error variable null ([cba0f9d](https://github.com/figorr/meteocatpy/commit/cba0f9d80c1b2a6e6f3ab8660b7ae703bfe4c148))
|
|
24
|
+
|
|
1
25
|
## [0.0.17](https://github.com/figorr/meteocatpy/compare/v0.0.16...v0.0.17) (2024-12-29)
|
|
2
26
|
|
|
3
27
|
|
package/meteocatpy/data.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import aiohttp
|
|
2
2
|
import logging
|
|
3
3
|
import re
|
|
4
|
-
from datetime import datetime
|
|
4
|
+
from datetime import datetime, timedelta
|
|
5
5
|
from .variables import MeteocatVariables
|
|
6
6
|
from .const import BASE_URL, STATION_DATA_URL
|
|
7
7
|
from .exceptions import (
|
|
@@ -41,6 +41,17 @@ class MeteocatStationData:
|
|
|
41
41
|
"""
|
|
42
42
|
now = datetime.now()
|
|
43
43
|
return now.year, now.month, now.day
|
|
44
|
+
|
|
45
|
+
@staticmethod
|
|
46
|
+
def get_previous_date():
|
|
47
|
+
"""
|
|
48
|
+
Obtiene la fecha del día anterior en formato numérico.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
tuple: Año (YYYY), mes (MM), día (DD) como enteros.
|
|
52
|
+
"""
|
|
53
|
+
yesterday = datetime.now() - timedelta(days=1)
|
|
54
|
+
return yesterday.year, yesterday.month, yesterday.day
|
|
44
55
|
|
|
45
56
|
async def get_station_data(self, station_id: str):
|
|
46
57
|
"""
|
|
@@ -66,7 +77,7 @@ class MeteocatStationData:
|
|
|
66
77
|
# Gestionar errores según el código de estado
|
|
67
78
|
if response.status == 400:
|
|
68
79
|
error_data = await response.json()
|
|
69
|
-
#
|
|
80
|
+
# Filtrar si el mensaje contiene una fecha válida
|
|
70
81
|
if "message" in error_data:
|
|
71
82
|
match = re.search(r'entre (\d{2}-\d{2}-\d{4}) i', error_data["message"])
|
|
72
83
|
if match:
|
|
@@ -82,6 +93,20 @@ class MeteocatStationData:
|
|
|
82
93
|
raise UnknownAPIError(
|
|
83
94
|
f"Failed with the valid date {last_valid_date}: {await new_response.text()}"
|
|
84
95
|
)
|
|
96
|
+
|
|
97
|
+
# Filtrar si el mensaje es "L'estació '<código>' no mesura la variable 'null'"
|
|
98
|
+
if re.search(r"L'estaci\u00f3 '.*?' no mesura la variable 'null'", error_data.get("message", "")):
|
|
99
|
+
any, mes, dia = self.get_previous_date() # Obtener la fecha del día anterior
|
|
100
|
+
new_url = f"{BASE_URL}{STATION_DATA_URL}".format(
|
|
101
|
+
codiEstacio=station_id, any=any, mes=f"{mes:02d}", dia=f"{dia:02d}"
|
|
102
|
+
)
|
|
103
|
+
async with session.get(new_url, headers=self.headers) as new_response:
|
|
104
|
+
if new_response.status == 200:
|
|
105
|
+
return await new_response.json()
|
|
106
|
+
raise UnknownAPIError(
|
|
107
|
+
f"Failed with the previous date: {await new_response.text()}"
|
|
108
|
+
)
|
|
109
|
+
|
|
85
110
|
raise BadRequestError(await response.json())
|
|
86
111
|
elif response.status == 403:
|
|
87
112
|
error_data = await response.json()
|
package/meteocatpy/version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# version.py
|
|
2
|
-
__version__ = "0.0.
|
|
2
|
+
__version__ = "0.0.20"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meteocatpy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"description": "[](https://opensource.org/licenses/Apache-2.0)\r [](https://pypi.org/project/meteocatpy)\r [](https://gitlab.com/figorr/meteocatpy/commits/master)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|