Fixed handling of stations with only arr/dep

This commit is contained in:
Dan Cojocaru 2021-08-27 22:48:58 +03:00
parent ddf9c27cc3
commit 5ab092eed5
Signed by: kbruen
GPG key ID: 818A889458EDC937
3 changed files with 11 additions and 6 deletions

View file

@ -46,6 +46,9 @@ def scrape(station_name: str):
tz = pytz.timezone('Europe/Bucharest')
def parse_arrdep_list(elem, end_station_field_name):
if elem.div.ul is None:
return None
def parse_item(elem):
result = {}

View file

@ -71,7 +71,7 @@
"type": "object",
"properties": {
"arrivals": {
"type": "array",
"type": ["array", "null"],
"items": {
"allOf": [
{
@ -96,7 +96,7 @@
}
},
"departures": {
"type": "array",
"type": ["array", "null"],
"items": {
"allOf": [
{

View file

@ -165,7 +165,9 @@ def on_station(station_data: dict):
found_train_at_station(station, train_number)
with db_transaction():
for train in station_data['arrivals']:
process_train(train)
for train in station_data['departures']:
process_train(train)
if station_data['arrivals']:
for train in station_data['arrivals']:
process_train(train)
if station_data['departures']:
for train in station_data['departures']:
process_train(train)