forked from robert-b-clarke/nre-darwin-py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
30 lines (24 loc) · 1.12 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from nredarwin.webservice import DarwinLdbSession
# initiate a session
# this depends on the DARWIN_WEBSERVICE_API_KEY environment variable
# The WSDL environment variable also allows for
darwin_session = DarwinLdbSession(wsdl='https://lite.realtime.nationalrail.co.uk/OpenLDBWS/wsdl.aspx')
print("Enter 3 digit CRS code:")
try:
input = raw_input #python2 has raw_input, python3 has input
except NameError:
pass
crs_code = input().upper()
# retrieve departure board
board = darwin_session.get_station_board(crs_code)
# print table header
print("\nNext departures for %s" % (board.location_name))
print("""
-------------------------------------------------------------------------------
| PLAT | DEST | SCHED | DUE |
------------------------------------------------------------------------------- """)
# Loop through services
for service in board.train_services:
print("| %6s | %43s | %9s | %8s |" %(service.platform or "", service.destination_text, service.std, service.etd))
# Print a footer
print("-------------------------------------------------------------------------------")