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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: openvan
3
- Version: 0.1.1
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:
@@ -8,7 +8,7 @@ from urllib.error import HTTPError, URLError
8
8
  from urllib.parse import urlencode
9
9
  from urllib.request import Request, urlopen
10
10
 
11
- __version__ = "0.1.1"
11
+ __version__ = "0.2.0"
12
12
 
13
13
  DEFAULT_BASE_URL = "https://openvan.camp"
14
14
 
@@ -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