PyTransportNSWv2 1.0.2__tar.gz → 1.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {PyTransportNSWv2-1.0.2 → PyTransportNSWv2-1.0.4}/PKG-INFO +1 -1
- {PyTransportNSWv2-1.0.2 → PyTransportNSWv2-1.0.4}/PyTransportNSWv2.egg-info/PKG-INFO +1 -1
- {PyTransportNSWv2-1.0.2 → PyTransportNSWv2-1.0.4}/TransportNSWv2/TransportNSWv2.py +22 -18
- PyTransportNSWv2-1.0.4/TransportNSWv2/__init__.py +2 -0
- {PyTransportNSWv2-1.0.2 → PyTransportNSWv2-1.0.4}/setup.py +1 -1
- PyTransportNSWv2-1.0.2/TransportNSWv2/__init__.py +0 -2
- {PyTransportNSWv2-1.0.2 → PyTransportNSWv2-1.0.4}/LICENSE +0 -0
- {PyTransportNSWv2-1.0.2 → PyTransportNSWv2-1.0.4}/PyTransportNSWv2.egg-info/SOURCES.txt +0 -0
- {PyTransportNSWv2-1.0.2 → PyTransportNSWv2-1.0.4}/PyTransportNSWv2.egg-info/TransportNSWv2.py +0 -0
- {PyTransportNSWv2-1.0.2 → PyTransportNSWv2-1.0.4}/PyTransportNSWv2.egg-info/dependency_links.txt +0 -0
- {PyTransportNSWv2-1.0.2 → PyTransportNSWv2-1.0.4}/PyTransportNSWv2.egg-info/requires.txt +0 -0
- {PyTransportNSWv2-1.0.2 → PyTransportNSWv2-1.0.4}/PyTransportNSWv2.egg-info/top_level.txt +0 -0
- {PyTransportNSWv2-1.0.2 → PyTransportNSWv2-1.0.4}/README.md +0 -0
- {PyTransportNSWv2-1.0.2 → PyTransportNSWv2-1.0.4}/setup.cfg +0 -0
@@ -88,15 +88,15 @@ class TransportNSWv2(object):
|
|
88
88
|
stop_list = []
|
89
89
|
skip_api_calls = False
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
91
|
+
try:
|
92
|
+
for stop in stops:
|
93
|
+
url = \
|
94
|
+
'https://api.transport.nsw.gov.au/v1/tp/stop_finder?' \
|
95
|
+
'outputFormat=rapidJSON&coordOutputFormat=EPSG%3A4326' \
|
96
|
+
'&type_sf=stop&name_sf=' + stop + \
|
97
|
+
'&TfNSWSF=true'
|
98
|
+
|
99
|
+
# Send the query
|
100
100
|
url = 'https://api.transport.nsw.gov.au/v1/tp/stop_finder?outputFormat=rapidJSON&coordOutputFormat=EPSG%3A4326&type_sf=stop&name_sf=' + stop + '&TfNSWSF=true'
|
101
101
|
error_code = 0
|
102
102
|
|
@@ -124,7 +124,6 @@ class TransportNSWv2(object):
|
|
124
124
|
else:
|
125
125
|
# Parse the result as a JSON object
|
126
126
|
stop_detail = response.json()
|
127
|
-
|
128
127
|
# Just a quick check - the presence of systemMessages signifies an error, otherwise we assume it's ok
|
129
128
|
if 'systemMessages' in stop_detail:
|
130
129
|
error_text = stop_detail['systemMessages'][0]['text']
|
@@ -134,10 +133,6 @@ class TransportNSWv2(object):
|
|
134
133
|
# Not usually an issue but if multiple processes are running multiple calls we might hit it
|
135
134
|
time.sleep(1.0)
|
136
135
|
|
137
|
-
except Exception as ex:
|
138
|
-
raise StopError(f"Error '{ex}' calling stop finder API for stop ID {stop}", stop)
|
139
|
-
|
140
|
-
finally:
|
141
136
|
# Append the results to the JSON output - only return the 'isBest' location entry if there's more than one
|
142
137
|
if stop_detail != []:
|
143
138
|
stop_valid = True
|
@@ -154,10 +149,19 @@ class TransportNSWv2(object):
|
|
154
149
|
data = {"stop_id": stop, "valid": stop_valid, "error_code": error_code, "stop_detail": stop_detail}
|
155
150
|
stop_list.append (data)
|
156
151
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
152
|
+
# Complete the JSON output and return it
|
153
|
+
data = {"all_stops_valid": all_stops_valid, "stop_list": stop_list}
|
154
|
+
|
155
|
+
return data
|
156
|
+
|
157
|
+
except InvalidAPIKey as ex:
|
158
|
+
raise InvalidAPIKey (f"Invalid API key {api_key}")
|
159
|
+
|
160
|
+
except StopError as ex:
|
161
|
+
raise StopError (f"Error '{ex}' calling stop finder API for stop ID {stop}")
|
162
|
+
|
163
|
+
except Exception as ex:
|
164
|
+
raise StopError(f"Error '{ex}' calling stop finder API for stop ID {stop}", stop)
|
161
165
|
|
162
166
|
|
163
167
|
def get_trip(self, name_origin, name_destination , api_key, journey_wait_time = 0, transport_type = 0, \
|
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|
5
5
|
|
6
6
|
setuptools.setup(
|
7
7
|
name="PyTransportNSWv2",
|
8
|
-
version="1.0.
|
8
|
+
version="1.0.4",
|
9
9
|
author="andystewart999",
|
10
10
|
author_email="andy.stewart@live.com",
|
11
11
|
description="Get detailed per-trip transport information from TransportNSW",
|
File without changes
|
File without changes
|
{PyTransportNSWv2-1.0.2 → PyTransportNSWv2-1.0.4}/PyTransportNSWv2.egg-info/TransportNSWv2.py
RENAMED
File without changes
|
{PyTransportNSWv2-1.0.2 → PyTransportNSWv2-1.0.4}/PyTransportNSWv2.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|