Repository: becheran/vgn (language: python)

Issue:
Error running sample code from README
```
Traceback (most recent call last):
  File "D:\repo\vgn\test.py", line 22, in <module>
    asyncio.run(main())
  File "C:\Users\a\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\a\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 649, in run_until_complete
    return future.result()
  File "D:\repo\vgn\test.py", line 7, in main
    res = await asyncio.gather(
  File "D:\repo\vgn\vgn\functions.py", line 40, in all_stations
    return conv.to_stations((await self._get(query)).get('Haltestellen'))
  File "D:\repo\vgn\vgn\converter.py", line 31, in to_stations
    return list(map(lambda x: Station(x.get('Haltestellenname'),
  File "D:\repo\vgn\vgn\converter.py", line 34, in <lambda>
    list(map(lambda z: _to_transport_type(z), x.get('Produkte').split(',')))
AttributeError: 'NoneType' object has no attribute 'split'
```


Discussion / hints:
I don't find the time to further maintain this project. If anybody out there wants further maintain/develop this code, please let me know.
> I don't find the time to further maintain this project. If anybody out there wants further maintain/develop this code, please let me know.

Hi,

I can take over maintaince of this project
> ```
> Traceback (most recent call last):
>   File "D:\repo\vgn\test.py", line 22, in <module>
>     asyncio.run(main())
>   File "C:\Users\a\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run
>     return loop.run_until_complete(main)
>   File "C:\Users\a\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 649, in run_until_complete
>     return future.result()
>   File "D:\repo\vgn\test.py", line 7, in main
>     res = await asyncio.gather(
>   File "D:\repo\vgn\vgn\functions.py", line 40, in all_stations
>     return conv.to_stations((await self._get(query)).get('Haltestellen'))
>   File "D:\repo\vgn\vgn\converter.py", line 31, in to_stations
>     return list(map(lambda x: Station(x.get('Haltestellenname'),
>   File "D:\repo\vgn\vgn\converter.py", line 34, in <lambda>
>     list(map(lambda z: _to_transport_type(z), x.get('Produkte').split(',')))
> AttributeError: 'NoneType' object has no attribute 'split'
> ```

That happens because VGN Rest API doesn't support possibility to get all stations any more. In the next release of "vgn" package the function "all_stations" will be removed.

Fix patch:
diff --git a/README.md b/README.md
index 7689d2b..7e96bda 100644
--- a/README.md
+++ b/README.md
@@ -28,17 +28,15 @@ async def main():
     async with vgn.VGNClient() as vgn_client:
         res = await asyncio.gather(
             vgn_client.api_version(),
-            vgn_client.all_stations(),
             vgn_client.departure_schedule(704),
             vgn_client.departure_schedule_for_line(704, "U2"),
             vgn_client.rides(vgn.TransportType.BUS, 30),
         )
 
     print(f'Api version: {res[0]}')
-    print(f'Stations in nbg: {str(len(res[1]))}')
-    print(f'Departures at plaerrer in nbg: {res[2]}')
-    print(f'Departures of underground line 2 at plaerrer in nbg: {res[3]}')
-    print(f'Bus departures in the next 30 minutes: {res[4]}')
+    print(f'Departures at plaerrer in nbg: {res[1]}')
+    print(f'Departures of underground line 2 at plaerrer in nbg: {res[2]}')
+    print(f'Bus departures in the next 30 minutes: {res[3]}')
 
 if __name__ == '__main__':
     asyncio.run(main())
diff --git a/vgn/functions.py b/vgn/functions.py
index d898719..2e030f9 100644
--- a/vgn/functions.py
+++ b/vgn/functions.py
@@ -30,15 +30,6 @@ async def api_version(self) -> str:
         query = self._url('haltestellen/VGN/location?lon=0&lat=0')
         return (await self._get(query)).get('Metadata').get('Version')
 
-    async def all_stations(self) -> List[Station]:
-        """ List of all stations.
-
-        Returns:
-            list: List of stations for the VGN transport association.
-        """
-        query = self._url(f'haltestellen/VGN')
-        return conv.to_stations((await self._get(query)).get('Haltestellen'))
-
     async def stations(self, station_name: str) -> List[Station]:
         """ List of stations for the specified station name.
 
@@ -177,16 +168,14 @@ async def main():
     async with VGNClient() as vgn_client:
         res = await asyncio.gather(
             vgn_client.api_version(),
-            vgn_client.all_stations(),
             vgn_client.departure_schedule(704),
             vgn_client.departure_schedule_for_line(704, "U2"),
             vgn_client.rides(TransportType.BUS, 30),
         )
     print(f'Api version: {res[0]}')
-    print(f'Stations in nbg: {str(len(res[1]))}')
-    print(f'Departures at plaerrer in nbg: {res[2]}')
-    print(f'Departures of underground line 2 at plaerrer in nbg: {res[3]}')
-    print(f'Bus departures in the next 30 minutes: {res[4]}')
+    print(f'Departures at plaerrer in nbg: {res[1]}')
+    print(f'Departures of underground line 2 at plaerrer in nbg: {res[2]}')
+    print(f'Bus departures in the next 30 minutes: {res[3]}')
 
 
 if __name__ == '__main__':


Test patch:
diff --git a/vgn/test_api.py b/vgn/test_api.py
index 40ef2a7..b9798d3 100644
--- a/vgn/test_api.py
+++ b/vgn/test_api.py
@@ -8,7 +8,7 @@
 @pytest.mark.asyncio
 async def test_api_version_did_not_change():
     async with VGNClient() as vgn_client:
-        assert (await vgn_client.api_version()) == 'Puls-API-v1.2'
+        assert (await vgn_client.api_version()) == 'Puls-API-v1.2.3'
 
 
 @pytest.mark.asyncio