summaryrefslogtreecommitdiff
path: root/windy.py
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-09-26 00:37:39 +0200
committerAki <please@ignore.pl>2022-09-26 00:37:39 +0200
commit78086bf15a335a9c40b5a58c2e563c0159870ed3 (patch)
tree3c3f4a24b41cd10ccd8990b7d6b78d5a5f22e731 /windy.py
parenta9e99607ec03e13bb2e819557174e0120b001255 (diff)
downloadwindy-78086bf15a335a9c40b5a58c2e563c0159870ed3.zip
windy-78086bf15a335a9c40b5a58c2e563c0159870ed3.tar.gz
windy-78086bf15a335a9c40b5a58c2e563c0159870ed3.tar.bz2
Made a proper package out of the module
Diffstat (limited to 'windy.py')
-rw-r--r--windy.py68
1 files changed, 0 insertions, 68 deletions
diff --git a/windy.py b/windy.py
deleted file mode 100644
index 2d5cab6..0000000
--- a/windy.py
+++ /dev/null
@@ -1,68 +0,0 @@
-from dataclasses import dataclass
-from enum import Enum
-
-import requests
-
-
-class _StrEnum(Enum):
- def __str__(self):
- return self.value
-
-
-class Model(_StrEnum):
- AROME = "arome"
- GEOS5 = "geos5"
- GFS = "gfs"
- GFSWAVE = "gfsWave"
- ICONEU = "iconEu"
- NAMALASKA = "namAlaska"
- NAMCONUS = "namConus"
- NAMHAWAII = "namHawaii"
-
-
-class Level(_StrEnum):
- SURFACE = "surface"
- H1000 = "1000h"
- H950 = "950h"
- H925 = "925h"
- H900 = "900h"
- H850 = "850h"
- H800 = "800h"
- H700 = "700h"
- H600 = "600h"
- H500 = "500h"
- H400 = "400h"
- H300 = "300h"
- H200 = "200h"
- H150 = "150h"
-
-
-@dataclass
-class Config:
- key: str
- api: str = "https://api.windy.com/api"
-
-
-@dataclass
-class Request:
- lat: float
- lon: float
- model: Model
- parameters: list = None
- levels: list = None
- endpoint: str = "/point-forecast/v2"
-
- def json(self):
- body = {
- 'lat': self.lat,
- 'lon': self.lon,
- 'model': str(self.model),
- 'parameters': self.parameters or [],
- }
- if self.levels:
- body['levels'] = [str(x) for x in self.levels]
- return body
-
-
-def point_forecast(request: Request, config: Config):
- return requests.post(config.api + request.endpoint, json=request.json())