Skip to content

Commit 20c7fa5

Browse files
committed
Add function to check multiple Velodi stations at a time + fix bug + bump version n° to 2.1
1 parent 4ffc462 commit 20c7fa5

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

divia_api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
__author__ = 'Firmin Launay'
2626
__license__ = 'LGPL-3.0'
2727
__copyright__ = 'divia_api Copyright (C) 2021 Firmin Launay'
28-
__version__ = '2.0'
28+
__version__ = '2.1'
2929

3030
from .api import DiviaAPI

divia_api/velodi.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,29 @@ def find_station(self, station_name: str) -> VelodiStation:
8686

8787
def get_station(self, station_code: str) -> VelodiStation:
8888
corresponding_stations = list(item for item in self.stations if item.code == station_code)
89-
if len(corresponding_stations > 0):
89+
if len(corresponding_stations) > 0:
9090
return corresponding_stations[0]
91+
92+
def find_stations(self, station_names: list) -> list:
93+
stations = []
94+
for station_name in station_names:
95+
stations.append(self.find_station(station_name))
96+
return stations
97+
98+
def get_stations(self, station_codes: list) -> list:
99+
stations = []
100+
for station_code in station_codes:
101+
stations.append(self.get_station(station_code))
102+
return stations
103+
104+
def check_multiple_stations(self, stations: list) -> list:
105+
velodi_data = update_source()
106+
results = []
107+
for station in stations:
108+
query_result = list(item for item in velodi_data if (item["infos"]["code_cykleo"] == station.code))
109+
try:
110+
free = query_result[0]["infos"]["qucit"]["realtime"]
111+
results.append(FreeVelodi(free["bikes"], free["docks"]))
112+
except IndexError:
113+
raise Exception("Data not found.")
114+
return results

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
setup(
3232
name='divia_api',
3333
packages=['divia_api'],
34-
version='2.0',
34+
version='2.1',
3535
license='LGPL-3.0',
3636
description='divia_api is a Python library that allows to retrieve the timetable of Divia’s bus and tramways, along with some infos about DiviaVélodi bikes, straight from a Python script.',
3737
long_description=long_description,
3838
long_description_content_type='text/markdown',
3939
author='Firmin Launay',
4040
author_email='hey@firminlaunay.me',
4141
url='https://github.com/filau/python_divia_api',
42-
download_url='https://github.com/filau/python_divia_api/archive/refs/tags/2.0.tar.gz',
42+
download_url='https://github.com/filau/python_divia_api/archive/refs/tags/2.1.tar.gz',
4343
keywords=['divia', 'api', 'firmin', 'launay', 'dijon', 'bus', 'tram'],
4444
install_requires=[
4545
'requests'

0 commit comments

Comments
 (0)