openvan 0.1.1__tar.gz → 0.2.0__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.
- {openvan-0.1.1 → openvan-0.2.0}/PKG-INFO +5 -1
- {openvan-0.1.1 → openvan-0.2.0}/README.md +4 -0
- {openvan-0.1.1 → openvan-0.2.0}/src/openvan/api.py +15 -0
- {openvan-0.1.1 → openvan-0.2.0}/src/openvan/client.py +1 -1
- {openvan-0.1.1 → openvan-0.2.0}/tests/test_openvan.py +15 -0
- {openvan-0.1.1 → openvan-0.2.0}/.gitignore +0 -0
- {openvan-0.1.1 → openvan-0.2.0}/LICENSE +0 -0
- {openvan-0.1.1 → openvan-0.2.0}/pyproject.toml +0 -0
- {openvan-0.1.1 → openvan-0.2.0}/src/openvan/__init__.py +0 -0
- {openvan-0.1.1 → openvan-0.2.0}/src/openvan/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: openvan
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Free vanlife & RV travel data: fuel prices in 160+ countries, toll roads, visa rules, holidays, travel hazards, weather scores, currency. No API key.
|
|
5
5
|
Project-URL: Homepage, https://openvan.camp/en/developers?utm_source=pypi&utm_medium=referral&utm_campaign=python-sdk
|
|
6
6
|
Project-URL: Documentation, https://openvan.camp/docs?utm_source=pypi&utm_medium=referral&utm_campaign=python-sdk
|
|
@@ -56,6 +56,10 @@ print(ov.tolls.route(["Rome", "Paris"], vehicle_class="van"))
|
|
|
56
56
|
for c in ov.weather.top(5):
|
|
57
57
|
print(c["code"], c["van_score"], c["score_label"])
|
|
58
58
|
|
|
59
|
+
# Typical weather (climate) in Batumi on 18 September and the best month to go
|
|
60
|
+
batumi = ov.weather.city_climate("GE", "batumi", date="09-18")
|
|
61
|
+
print(batumi["day"]["temp_day_c"], batumi["day"]["precipitation_days_of_35"], batumi["best_month"])
|
|
62
|
+
|
|
59
63
|
# School holidays in Germany this autumn, by federal state
|
|
60
64
|
ov.holidays.country("DE", from_="2026-10-01", to="2026-12-31", kind="school")
|
|
61
65
|
```
|
|
@@ -32,6 +32,10 @@ print(ov.tolls.route(["Rome", "Paris"], vehicle_class="van"))
|
|
|
32
32
|
for c in ov.weather.top(5):
|
|
33
33
|
print(c["code"], c["van_score"], c["score_label"])
|
|
34
34
|
|
|
35
|
+
# Typical weather (climate) in Batumi on 18 September and the best month to go
|
|
36
|
+
batumi = ov.weather.city_climate("GE", "batumi", date="09-18")
|
|
37
|
+
print(batumi["day"]["temp_day_c"], batumi["day"]["precipitation_days_of_35"], batumi["best_month"])
|
|
38
|
+
|
|
35
39
|
# School holidays in Germany this autumn, by federal state
|
|
36
40
|
ov.holidays.country("DE", from_="2026-10-01", to="2026-12-31", kind="school")
|
|
37
41
|
```
|
|
@@ -151,6 +151,21 @@ class Weather(_Resource):
|
|
|
151
151
|
"""Top countries by vanlife weather suitability today, best first."""
|
|
152
152
|
return sorted(self.all(), key=lambda c: c.get("van_score") or 0, reverse=True)[:limit]
|
|
153
153
|
|
|
154
|
+
def climate(self, lat: float, lng: float, date: Optional[str] = None) -> JSON:
|
|
155
|
+
"""Typical weather (climate) at any point: median of 35 archive days (the date ±3 days over
|
|
156
|
+
2021–2025, ERA5). With ``date`` (``MM-DD`` or ``YYYY-MM-DD``) the result has ``day``; without it,
|
|
157
|
+
``days`` holds all 366 days. ``months``, ``best_month`` and ``good_months`` are always included.
|
|
158
|
+
"""
|
|
159
|
+
return self.client.get("/api/vansky/climate", {"lat": lat, "lng": lng, "date": date})
|
|
160
|
+
|
|
161
|
+
def city_climate(
|
|
162
|
+
self, code: str, city_slug: str, date: Optional[str] = None, locale: Optional[str] = None
|
|
163
|
+
) -> JSON:
|
|
164
|
+
"""The same as :meth:`climate` for a VanSky city, plus the city name and page URL."""
|
|
165
|
+
return self.client.get(
|
|
166
|
+
f"/api/vansky/climate/{code.upper()}/{quote(city_slug)}", {"date": date, "locale": locale}
|
|
167
|
+
)
|
|
168
|
+
|
|
154
169
|
|
|
155
170
|
class Events(_Resource):
|
|
156
171
|
def list(self, **filters: Any) -> JSON:
|
|
@@ -104,6 +104,21 @@ class OpenVanTest(unittest.TestCase):
|
|
|
104
104
|
with mock.patch("openvan.client.urlopen", fake):
|
|
105
105
|
self.assertEqual([c["code"] for c in OpenVan().weather.top(2)], ["B", "C"])
|
|
106
106
|
|
|
107
|
+
def test_climate_point_passes_lat_lng_and_date(self):
|
|
108
|
+
fake, calls = respond({"/api/vansky/climate": {"period": "2021–2025", "day": {"date": "09-18"}}})
|
|
109
|
+
with mock.patch("openvan.client.urlopen", fake):
|
|
110
|
+
self.assertEqual(OpenVan().weather.climate(41.64, 41.63, "09-18")["day"]["date"], "09-18")
|
|
111
|
+
q = parse_qs(urlparse(calls[0].full_url).query)
|
|
112
|
+
self.assertEqual((q["lat"], q["lng"], q["date"]), (["41.64"], ["41.63"], ["09-18"]))
|
|
113
|
+
|
|
114
|
+
def test_city_climate_without_date_drops_empty_params(self):
|
|
115
|
+
fake, calls = respond({"/api/vansky/climate/GE/batumi": {"period": "2021–2025", "months": []}})
|
|
116
|
+
with mock.patch("openvan.client.urlopen", fake):
|
|
117
|
+
OpenVan().weather.city_climate("ge", "batumi")
|
|
118
|
+
url = urlparse(calls[0].full_url)
|
|
119
|
+
self.assertEqual(url.path, "/api/vansky/climate/GE/batumi")
|
|
120
|
+
self.assertNotIn("date", parse_qs(url.query))
|
|
121
|
+
|
|
107
122
|
def test_route_cost_posts_json(self):
|
|
108
123
|
fake, calls = respond({"/api/route-cost": {"distance_km": 345}})
|
|
109
124
|
with mock.patch("openvan.client.urlopen", fake):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|