Skip to content

Commit ad73f3c

Browse files
bird converter
1 parent ab0f957 commit ad73f3c

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
The changelog lists relevant feature changes between each release. Search GitHub issues and pull requests for smaller issues.
44

55
## Upcoming release (under development)
6+
- add converter for `mds.bird.co` feed: remove `station_information`, `station_status` and `free_bike_status` feeds from gbfs.json if they are always empty.
67

78
## 2024-06-14
89
- add converter for `data.lime.bike` feed: remove `station_status` and `station_information` feeds from gbfs.json, as Lime associates all free floating bikes to a single station, which is semantically wrong.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from typing import List, Union
2+
3+
from app.base_converter import BaseConverter
4+
5+
6+
class GbfsBirdRemoveStationsOrVehiclesConverter(BaseConverter):
7+
hostnames = ['mds.bird.co']
8+
9+
@staticmethod
10+
def _get_system_id_from_path(path: str) -> str:
11+
return path.split('/')[-3:-2][0]
12+
13+
def convert(self, data: Union[dict, list], path: str) -> Union[dict, list]:
14+
if not path.endswith('/gbfs.json') or not isinstance(data, dict) or not isinstance(data.get('data'), dict):
15+
return data
16+
17+
system_id = self._get_system_id_from_path(path)
18+
for language in data['data']:
19+
if not isinstance(data['data'][language].get('feeds'), list):
20+
continue
21+
22+
new_feeds = []
23+
for feed in data['data'][language]['feeds']:
24+
if not isinstance(feed, dict):
25+
continue
26+
if system_id in ['basel', 'biel', 'kloten', 'zurich'] and feed.get('name') in ['station_information', 'station_status']:
27+
continue
28+
if system_id in ['sarreguemines'] and feed.get('name') in ['free_bike_status']:
29+
continue
30+
new_feeds.append(feed)
31+
32+
data['data'][language]['feeds'] = new_feeds
33+
34+
return data

0 commit comments

Comments
 (0)