hamsclientfork 0.2.13__tar.gz → 0.2.15__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.13
3
+ Version: 0.2.15
4
4
  Summary: Library to get data from meteo swiss
5
5
  Home-page: https://github.com/Rudd-O/hamsclientfork
6
6
  Author: websylv
@@ -16,7 +16,6 @@ Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  License-File: LICENSE
18
18
  Requires-Dist: requests>=2.22.0
19
- Requires-Dist: pandas>=0.25.3
20
19
  Requires-Dist: beautifulsoup4>=4.8.2
21
20
  Requires-Dist: geopy>=2.0.0
22
21
 
@@ -2,9 +2,9 @@ import geopy
2
2
  import geopy.distance
3
3
  import json
4
4
  import logging
5
- import pandas as pd
6
5
  import requests # type: ignore
7
6
  import datetime
7
+ import csv
8
8
 
9
9
  from bs4 import BeautifulSoup
10
10
  from enum import Enum
@@ -287,7 +287,12 @@ class meteoSwissClient:
287
287
 
288
288
  def get_current_condition(self):
289
289
  _LOGGER.debug("Update current condition")
290
- data = pd.read_csv(CURRENT_CONDITION_URL, sep=";", header=0)
290
+ with requests.get(CURRENT_CONDITION_URL) as response:
291
+ response.raise_for_status()
292
+ response.encoding = "iso_8859_1"
293
+ lines = response.text.split("\n")
294
+ csv_reader = csv.DictReader(lines, delimiter=";")
295
+ data = [row for row in csv_reader if row]
291
296
  conditions = {}
292
297
  condition_list = []
293
298
  for station in self._stations:
@@ -295,7 +300,8 @@ class meteoSwissClient:
295
300
  stationData = data.loc[data["Station/Location"].str.contains(station)]
296
301
  stationData = stationData.to_dict("records")
297
302
  condition_list.extend(stationData)
298
- conditions[station] = stationData[0]
303
+ if stationData:
304
+ conditions[station] = stationData[0]
299
305
  self._condition = condition_list
300
306
  self._conditions = conditions
301
307
 
@@ -305,16 +311,19 @@ class meteoSwissClient:
305
311
 
306
312
  def __get_all_stations(self) -> dict[str, Any]:
307
313
  _LOGGER.debug("Getting all stations from : %s" % (STATION_URL))
308
- data = pd.read_csv(
309
- STATION_URL,
310
- sep=";",
311
- header=0,
312
- skipfooter=4,
313
- encoding="latin1",
314
- engine="python",
315
- )
314
+ with requests.get(STATION_URL) as response:
315
+ response.encoding = "iso_8859_1"
316
+ lines = response.text.split("\n")
317
+ csv_reader = csv.DictReader(lines, delimiter=";")
318
+ data = [row for row in csv_reader if row]
319
+
316
320
  stationList = {}
317
- for index, line in data.iterrows():
321
+ for line in data:
322
+ if (
323
+ line["Type de station"] != STATION_TYPE_PRECIPITATION
324
+ and line["Type de station"] != STATION_TYPE_WEATHER
325
+ ):
326
+ continue
318
327
  stationData = {}
319
328
  stationData["code"] = line["Abr."]
320
329
  stationData["name"] = line["Station"]
@@ -326,7 +335,7 @@ class meteoSwissClient:
326
335
  elif line["Type de station"] == STATION_TYPE_WEATHER:
327
336
  stationData["type"] = StationType.WEATHER
328
337
  else:
329
- assert 0, "unknown station type %s" % line["Type de station"]
338
+ _LOGGER.debug("unknown station type %s" % line["Type de station"])
330
339
  stationList[stationData["code"]] = stationData
331
340
  return stationList
332
341
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hamsclientfork
3
- Version: 0.2.13
3
+ Version: 0.2.15
4
4
  Summary: Library to get data from meteo swiss
5
5
  Home-page: https://github.com/Rudd-O/hamsclientfork
6
6
  Author: websylv
@@ -16,7 +16,6 @@ Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  License-File: LICENSE
18
18
  Requires-Dist: requests>=2.22.0
19
- Requires-Dist: pandas>=0.25.3
20
19
  Requires-Dist: beautifulsoup4>=4.8.2
21
20
  Requires-Dist: geopy>=2.0.0
22
21
 
@@ -1,4 +1,3 @@
1
1
  requests>=2.22.0
2
- pandas>=0.25.3
3
2
  beautifulsoup4>=4.8.2
4
3
  geopy>=2.0.0
@@ -15,7 +15,7 @@ def read(filename):
15
15
 
16
16
  setup(
17
17
  name="hamsclientfork",
18
- version="0.2.13",
18
+ version="0.2.15",
19
19
  url="https://github.com/Rudd-O/hamsclientfork",
20
20
  license="MIT",
21
21
  author="websylv",
@@ -25,7 +25,6 @@ setup(
25
25
  packages=find_packages(exclude=("tests",)),
26
26
  install_requires=[
27
27
  "requests>=2.22.0",
28
- "pandas>=0.25.3",
29
28
  "beautifulsoup4>=4.8.2",
30
29
  "geopy>=2.0.0",
31
30
  ],
File without changes
File without changes