hamsclientfork 0.2.12__tar.gz → 0.2.13__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.12
3
+ Version: 0.2.13
4
4
  Summary: Library to get data from meteo swiss
5
5
  Home-page: https://github.com/Rudd-O/hamsclientfork
6
6
  Author: websylv
@@ -190,7 +190,11 @@ def CurrentCondition_from_meteoswiss_data(data: dict[str, Any]) -> CurrentCondit
190
190
  class ClientResult(TypedDict):
191
191
  name: str
192
192
  forecast: Forecast
193
+ # A list of current conditions for the first station passed.
193
194
  condition: list[CurrentCondition]
195
+ # A dictionary of station -> list of the current condition
196
+ # returned by the corresponding station.
197
+ condition_by_station: dict[str, CurrentCondition]
194
198
 
195
199
 
196
200
  def ClientResult_from_meteoswiss_data(data: dict[str, Any]) -> ClientResult:
@@ -198,21 +202,26 @@ def ClientResult_from_meteoswiss_data(data: dict[str, Any]) -> ClientResult:
198
202
  name=data["name"],
199
203
  forecast=Forecast_from_meteoswiss_data(data["forecast"]),
200
204
  condition=[CurrentCondition_from_meteoswiss_data(x) for x in data["condition"]],
205
+ condition_by_station={
206
+ station: CurrentCondition_from_meteoswiss_data(condition)
207
+ for (station, condition) in data["condition_by_station"].items()
208
+ },
201
209
  )
202
210
 
203
211
 
204
212
  class meteoSwissClient:
205
- def __init__(self, displayName=None, postcode=None, station=None):
213
+ def __init__(self, displayName=None, postcode=None, *station: str):
206
214
  _LOGGER.debug("MS Client INIT")
207
215
  self._postCode = postcode
208
- self._station = station
216
+ self._stations = station
209
217
  self._name = displayName
210
- self._allStations = None
218
+ self._allStations: dict[str, Any] | None = None
211
219
  self._condition = None
220
+ self._conditions: dict[str, Any] = {}
212
221
  self._forecast = None
213
222
  _LOGGER.debug(
214
- "INIT meteoswiss client : name = %s station = %s postcode = %s"
215
- % (self._name, self._station, self._postCode)
223
+ "INIT meteoswiss client : name = %s stations = %s postcode = %s"
224
+ % (self._name, self._stations, self._postCode)
216
225
  )
217
226
 
218
227
  def get_data(self):
@@ -222,6 +231,7 @@ class meteoSwissClient:
222
231
  "name": self._name,
223
232
  "forecast": self._forecast,
224
233
  "condition": self._condition,
234
+ "condition_by_station": self._conditions,
225
235
  }
226
236
 
227
237
  def get_typed_data(self) -> ClientResult:
@@ -277,19 +287,23 @@ class meteoSwissClient:
277
287
 
278
288
  def get_current_condition(self):
279
289
  _LOGGER.debug("Update current condition")
280
-
281
290
  data = pd.read_csv(CURRENT_CONDITION_URL, sep=";", header=0)
282
-
283
- _LOGGER.debug("Get current condition for : %s" % self._station)
284
- stationData = data.loc[data["Station/Location"].str.contains(self._station)]
285
- stationData = stationData.to_dict("records")
286
- self._condition = stationData
291
+ conditions = {}
292
+ condition_list = []
293
+ for station in self._stations:
294
+ _LOGGER.debug("Get current condition for : %s" % station)
295
+ stationData = data.loc[data["Station/Location"].str.contains(station)]
296
+ stationData = stationData.to_dict("records")
297
+ condition_list.extend(stationData)
298
+ conditions[station] = stationData[0]
299
+ self._condition = condition_list
300
+ self._conditions = conditions
287
301
 
288
302
  def update(self):
289
303
  self.get_forecast()
290
304
  self.get_current_condition()
291
305
 
292
- def __get_all_stations(self):
306
+ def __get_all_stations(self) -> dict[str, Any]:
293
307
  _LOGGER.debug("Getting all stations from : %s" % (STATION_URL))
294
308
  data = pd.read_csv(
295
309
  STATION_URL,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hamsclientfork
3
- Version: 0.2.12
3
+ Version: 0.2.13
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,7 +15,7 @@ def read(filename):
15
15
 
16
16
  setup(
17
17
  name="hamsclientfork",
18
- version="0.2.12",
18
+ version="0.2.13",
19
19
  url="https://github.com/Rudd-O/hamsclientfork",
20
20
  license="MIT",
21
21
  author="websylv",
File without changes
File without changes