hamsclientfork 0.2.8__tar.gz → 0.2.10__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.1
2
2
  Name: hamsclientfork
3
- Version: 0.2.8
3
+ Version: 0.2.10
4
4
  Summary: Library to get data from meteo swiss
5
5
  Home-page: https://github.com/Rudd-O/hamsclientfork
6
6
  Author: websylv
@@ -15,6 +15,10 @@ Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  License-File: LICENSE
18
+ Requires-Dist: requests>=2.22.0
19
+ Requires-Dist: pandas>=0.25.3
20
+ Requires-Dist: beautifulsoup4>=4.8.2
21
+ Requires-Dist: geopy>=2.0.0
18
22
 
19
23
  meteoswiss
20
24
  ==========
@@ -325,21 +325,26 @@ class meteoSwissClient:
325
325
  _LOGGER.warning("Unable to find station name for : %s" % (stationId))
326
326
  return None
327
327
 
328
- def getGeoData(self, lat, lon):
328
+ def getGeoData(self, lat, lon, user_agent=None):
329
329
  s = requests.Session()
330
- lat = str(lat)
331
- lon = str(lon)
332
330
  s.headers.update(_HEADERS)
331
+ if user_agent:
332
+ s.headers.update({"User-Agent": user_agent})
333
333
 
334
- geoData = s.get(
335
- "https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat="
336
- + lat
337
- + "&lon="
338
- + lon
339
- + "&zoom=18"
340
- ).text
341
- _LOGGER.debug("Got data from OpenStreetMap: %s" % (geoData))
342
- return json.loads(geoData)
334
+ uri = (
335
+ "https://nominatim.openstreetmap.org/reverse"
336
+ f"?format=jsonv2&lat={lat}&lon={lon}&zoom=18"
337
+ )
338
+ _LOGGER.debug("Requesting Nominatim OSM data at URL %s", uri)
339
+ geoData_req = s.get(uri)
340
+ try:
341
+ geoData_req.raise_for_status()
342
+ geoData = geoData_req.json()
343
+ _LOGGER.debug("Got data from OpenStreetMap: %s" % (geoData))
344
+ return geoData
345
+ except Exception:
346
+ _LOGGER.exception("Cannot get Nominatim OSM data: %s", geoData_req.text)
347
+ raise
343
348
 
344
349
  def getPostCode(self, lat, lon):
345
350
  geoData = self.getGeoData(lat, lon)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hamsclientfork
3
- Version: 0.2.8
3
+ Version: 0.2.10
4
4
  Summary: Library to get data from meteo swiss
5
5
  Home-page: https://github.com/Rudd-O/hamsclientfork
6
6
  Author: websylv
@@ -15,6 +15,10 @@ Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  License-File: LICENSE
18
+ Requires-Dist: requests>=2.22.0
19
+ Requires-Dist: pandas>=0.25.3
20
+ Requires-Dist: beautifulsoup4>=4.8.2
21
+ Requires-Dist: geopy>=2.0.0
18
22
 
19
23
  meteoswiss
20
24
  ==========
@@ -15,7 +15,7 @@ def read(filename):
15
15
 
16
16
  setup(
17
17
  name="hamsclientfork",
18
- version="0.2.8",
18
+ version="0.2.10",
19
19
  url="https://github.com/Rudd-O/hamsclientfork",
20
20
  license="MIT",
21
21
  author="websylv",
File without changes
File without changes