PyTransportNSWv2 0.3.1__py3-none-any.whl → 0.3.4__py3-none-any.whl
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-0.3.1.dist-info → PyTransportNSWv2-0.3.4.dist-info}/LICENSE +0 -0
- {PyTransportNSWv2-0.3.1.dist-info → PyTransportNSWv2-0.3.4.dist-info}/METADATA +16 -3
- PyTransportNSWv2-0.3.4.dist-info/RECORD +7 -0
- TransportNSW/TransportNSW.py +13 -3
- PyTransportNSWv2-0.3.1.dist-info/RECORD +0 -7
- {PyTransportNSWv2-0.3.1.dist-info → PyTransportNSWv2-0.3.4.dist-info}/WHEEL +0 -0
- {PyTransportNSWv2-0.3.1.dist-info → PyTransportNSWv2-0.3.4.dist-info}/top_level.txt +0 -0
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: PyTransportNSWv2
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.4
|
4
4
|
Summary: Get detailed per-trip transport information from TransportNSW
|
5
5
|
Home-page: https://github.com/andystewart999/TransportNSW
|
6
6
|
Author: andystewart999
|
@@ -12,6 +12,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
12
12
|
Description-Content-Type: text/markdown
|
13
13
|
License-File: LICENSE
|
14
14
|
Requires-Dist: gtfs-realtime-bindings
|
15
|
+
Requires-Dist: requests
|
15
16
|
|
16
17
|
# TransportNSW
|
17
18
|
Python lib to access Transport NSW information.
|
@@ -34,9 +35,21 @@ The source API details can be found here: https://opendata.transport.nsw.gov.au/
|
|
34
35
|
```python
|
35
36
|
.get_trip(origin_stop_id, destination_stop_id, api_key, [trip_wait_time = 0], [transport_type = 0])
|
36
37
|
```
|
37
|
-
|
38
38
|
TransportNSW's trip planner can work better if you use the general location IDs (eg Central Station) rather than a specific Stop ID (eg Central Station, Platform 19) for the destination, depending on the transport type. Forcing a specific end destination sometimes results in much more complicated trips. Also note that the API expects (and returns) the Stop IDs as strings, although so far they all appear to be numeric.
|
39
39
|
|
40
|
+
### transport_type filters
|
41
|
+
```
|
42
|
+
1: Train
|
43
|
+
4: Light rail
|
44
|
+
5: Bus
|
45
|
+
7: Coach
|
46
|
+
9: Ferry
|
47
|
+
11: School bus
|
48
|
+
99: Walk
|
49
|
+
100: Walk
|
50
|
+
107: Cycle
|
51
|
+
```
|
52
|
+
|
40
53
|
### Sample Code
|
41
54
|
|
42
55
|
The following example will return the next trip that starts from a bus stop in St. Ives (207537) five minutes from now, to Central Station's general stop ID (10101100):
|
@@ -52,7 +65,7 @@ print(journey)
|
|
52
65
|
```python
|
53
66
|
{"due": 3, "origin_stop_id": "207537", "origin_name": "Mona Vale Rd at Shinfield Ave, St Ives", "departure_time": "2024-05-20T21:59:48Z", "destination_stop_id": "2000338", "destination_name": "Central Station, Platform 18, Sydney", "arrival_time": "2024-05-20T22:47:36Z", "origin_transport_type": "Bus", "origin_transport_name": "Sydney Buses Network", "origin_line_name": "195", "origin_line_name_short": "195", "changes": 1, "occupancy": "MANY_SEATS", "real_time_trip_id": "2096551", "latitude": -33.72665786743164, "longitude": 151.16305541992188}
|
54
67
|
```
|
55
|
-
Fun fact: TransportNSW's raw API output calls itself JSON, but it uses single quotes for strings in defiance of the JSON standards. When using this wrapper the output is formatted such that `jq`, for example, is happy with.
|
68
|
+
Fun fact: TransportNSW's raw API output calls itself JSON, but it uses single quotes for strings in defiance of the JSON standards. When using this wrapper the output is formatted such that `jq`, for example, is happy with it.
|
56
69
|
|
57
70
|
* due: the time (in minutes) before the journey starts
|
58
71
|
* origin_stop_id: the specific departure stop id
|
@@ -0,0 +1,7 @@
|
|
1
|
+
TransportNSW/TransportNSW.py,sha256=AbgpP6PgHqVjB7LhNI9cT3q7O9ySUMnI057k7mmYLyQ,13926
|
2
|
+
TransportNSW/__init__.py,sha256=O3iuSkUGkkDz4C7IlqvOXJHPJTxYz0q_48-94ESlkdg,86
|
3
|
+
PyTransportNSWv2-0.3.4.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
4
|
+
PyTransportNSWv2-0.3.4.dist-info/METADATA,sha256=vN1ZaUheTpFBEe_mj1aERCNP3ecrGmPGFCOsn0VizYU,5481
|
5
|
+
PyTransportNSWv2-0.3.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
+
PyTransportNSWv2-0.3.4.dist-info/top_level.txt,sha256=C4LQEkr85VJtG9cklBu9IFpSKRaNSADPBTSPeXIYnOw,13
|
7
|
+
PyTransportNSWv2-0.3.4.dist-info/RECORD,,
|
TransportNSW/TransportNSW.py
CHANGED
@@ -157,7 +157,7 @@ class TransportNSW(object):
|
|
157
157
|
origin_name = origin['name']
|
158
158
|
origin_departure_time = origin['departureTimeEstimated']
|
159
159
|
|
160
|
-
|
160
|
+
# How long until it leaves?
|
161
161
|
due = self.get_due(datetime.strptime(origin_departure_time, fmt))
|
162
162
|
|
163
163
|
# Destination info
|
@@ -276,7 +276,12 @@ class TransportNSW(object):
|
|
276
276
|
for leg in range (0, leg_count, 1):
|
277
277
|
leg_class = legs[leg]['transportation']['product']['class']
|
278
278
|
|
279
|
-
|
279
|
+
# We've got a filter, and the leg type matches it, so return it
|
280
|
+
if legtype != 0 and leg_class == legtype:
|
281
|
+
return leg
|
282
|
+
|
283
|
+
# We don't have a filter, and this is the first non-walk/cycle leg so return it
|
284
|
+
if legtype == 0 and leg_class < 99:
|
280
285
|
return leg
|
281
286
|
|
282
287
|
# Hmm, we didn't find one
|
@@ -289,7 +294,12 @@ class TransportNSW(object):
|
|
289
294
|
for leg in range (leg_count - 1, -1, -1):
|
290
295
|
leg_class = legs[leg]['transportation']['product']['class']
|
291
296
|
|
292
|
-
|
297
|
+
# We've got a filter, and the leg type matches it, so return it
|
298
|
+
if legtype != 0 and leg_class == legtype:
|
299
|
+
return leg
|
300
|
+
|
301
|
+
# We don't have a filter, and this is the first non-walk/cycle leg so return it
|
302
|
+
if legtype == 0 and leg_class < 99:
|
293
303
|
return leg
|
294
304
|
|
295
305
|
# Hmm, we didn't find one
|
@@ -1,7 +0,0 @@
|
|
1
|
-
TransportNSW/TransportNSW.py,sha256=dKbYIRSLJUqmJHDH5ZOdLWK5mObW4uxGb89l1Um9_-k,13395
|
2
|
-
TransportNSW/__init__.py,sha256=O3iuSkUGkkDz4C7IlqvOXJHPJTxYz0q_48-94ESlkdg,86
|
3
|
-
PyTransportNSWv2-0.3.1.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
4
|
-
PyTransportNSWv2-0.3.1.dist-info/METADATA,sha256=fFZtnw4SXZZfkjGktIEW29Qaj3Re0QDPmxXfGmM2ddk,5326
|
5
|
-
PyTransportNSWv2-0.3.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
-
PyTransportNSWv2-0.3.1.dist-info/top_level.txt,sha256=C4LQEkr85VJtG9cklBu9IFpSKRaNSADPBTSPeXIYnOw,13
|
7
|
-
PyTransportNSWv2-0.3.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|