hamsclientfork 0.2.14__tar.gz → 0.2.16__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.14
3
+ Version: 0.2.16
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,13 +287,17 @@ 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:
294
299
  _LOGGER.debug("Get current condition for : %s" % station)
295
- stationData = data.loc[data["Station/Location"].str.contains(station)]
296
- stationData = stationData.to_dict("records")
300
+ stationData = [d for d in data if d["Station/Location"] == station]
297
301
  condition_list.extend(stationData)
298
302
  if stationData:
299
303
  conditions[station] = stationData[0]
@@ -306,16 +310,19 @@ class meteoSwissClient:
306
310
 
307
311
  def __get_all_stations(self) -> dict[str, Any]:
308
312
  _LOGGER.debug("Getting all stations from : %s" % (STATION_URL))
309
- data = pd.read_csv(
310
- STATION_URL,
311
- sep=";",
312
- header=0,
313
- skipfooter=4,
314
- encoding="latin1",
315
- engine="python",
316
- )
313
+ with requests.get(STATION_URL) as response:
314
+ response.encoding = "iso_8859_1"
315
+ lines = response.text.split("\n")
316
+ csv_reader = csv.DictReader(lines, delimiter=";")
317
+ data = [row for row in csv_reader if row]
318
+
317
319
  stationList = {}
318
- for index, line in data.iterrows():
320
+ for line in data:
321
+ if (
322
+ line["Type de station"] != STATION_TYPE_PRECIPITATION
323
+ and line["Type de station"] != STATION_TYPE_WEATHER
324
+ ):
325
+ continue
319
326
  stationData = {}
320
327
  stationData["code"] = line["Abr."]
321
328
  stationData["name"] = line["Station"]
@@ -327,7 +334,7 @@ class meteoSwissClient:
327
334
  elif line["Type de station"] == STATION_TYPE_WEATHER:
328
335
  stationData["type"] = StationType.WEATHER
329
336
  else:
330
- assert 0, "unknown station type %s" % line["Type de station"]
337
+ _LOGGER.debug("unknown station type %s" % line["Type de station"])
331
338
  stationList[stationData["code"]] = stationData
332
339
  return stationList
333
340
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hamsclientfork
3
- Version: 0.2.14
3
+ Version: 0.2.16
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.14",
18
+ version="0.2.16",
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