Skip to content

Commit 84e4b87

Browse files
committed
Remove occupancy from output
The occupancy isn't provided anymore by the API since 2017: OpendataCH/Transport#163 Since we now have more space available, I renamed the "Chg." column to "Changes".
1 parent 251c7be commit 84e4b87

File tree

4 files changed

+3
-24
lines changed

4 files changed

+3
-24
lines changed

Diff for: fahrplan/api.py

+1-20
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66
import sys
77
from .helpers import perror
88

9-
occupancies = {
10-
None: '',
11-
-1: '',
12-
0: 'Low', # todo check
13-
1: 'Low',
14-
2: 'Medium',
15-
3: 'High',
16-
}
179
API_URL = 'http://transport.opendata.ch/v1'
1810

1911

@@ -68,15 +60,6 @@ def _parse_section(con_section, connection):
6860
section['arrival'] = dateutil.parser.parse(arrival['arrival'])
6961
section['platform_from'] = "" if walk else departure['platform']
7062
section['platform_to'] = arrival['platform']
71-
if walk:
72-
section['occupancy1st'] = ''
73-
section['occupancy2nd'] = ''
74-
elif journey:
75-
section['occupancy1st'] = occupancies.get(con_section['journey']['capacity1st'], '')
76-
section['occupancy2nd'] = occupancies.get(con_section['journey']['capacity2nd'], '')
77-
else:
78-
section['occupancy1st'] = occupancies.get(connection['capacity1st'], '')
79-
section['occupancy2nd'] = occupancies.get(connection['capacity2nd'], '')
8063
return section
8164

8265

@@ -107,8 +90,6 @@ def keyfunc(s):
10790
in connection['sections']
10891
if section['journey'] is not None
10992
)
110-
data['occupancy1st'] = occupancies.get(connection['capacity1st'], '')
111-
data['occupancy2nd'] = occupancies.get(connection['capacity2nd'], '')
11293

11394
# Sections
11495
con_sections = sorted(connection['sections'], key=keyfunc)
@@ -127,7 +108,7 @@ def keyfunc(s):
127108
for p in ["station_to", "arrival"]:
128109
section[p] = to[p]
129110
# Get information from connection
130-
for p in ["occupancy2nd", "occupancy1st", "travelwith", "change_count"]:
111+
for p in ["travelwith", "change_count"]:
131112
section[p] = data[p]
132113
data['sections'] = [section]
133114

Diff for: fahrplan/display.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def _get_connection_row(i, connection):
2323
lambda x: [str((x['arrival'] - x['departure'])).rsplit(':', 1)[0], ' '], # Duration
2424
None,
2525
lambda x: [x['travelwith'], ' '], # With
26-
lambda x: ['1: ' + x['occupancy1st'], '2: ' + x['occupancy2nd']] # Occupancy
2726
]:
2827
if p is None:
2928
row.append(connection['change_count'])
@@ -46,9 +45,8 @@ def connectionsTable(connections, output_format):
4645
table.add_column("Date", justify="left", vertical="top")
4746
table.add_column("Time", justify="left", vertical="top")
4847
table.add_column("Duration", justify="center", vertical="top")
49-
table.add_column("Chg.", justify="center", vertical="middle")
48+
table.add_column("Changes", justify="center", vertical="middle")
5049
table.add_column("With", justify="left", vertical="top")
51-
table.add_column("Occupancy", justify="left", vertical="top")
5250
# Connection rows
5351
for i, connection in enumerate(connections):
5452
table.add_row(*_get_connection_row(i, connection))

Diff for: fahrplan/tests/test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def testRowCount(self):
202202
def testHeadline(self):
203203
"""Test the headline items."""
204204
headline_items = ['Station', 'Platform', 'Date', 'Time',
205-
'Duration', 'Chg.', 'With', 'Occupancy']
205+
'Duration', 'Changes', 'With']
206206
for item in headline_items:
207207
self.assertIn(item, self.rows[1])
208208

Diff for: screenshot.png

29.7 KB
Loading

0 commit comments

Comments
 (0)