PyTransportNSWv2 0.3.2__tar.gz → 0.3.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyTransportNSWv2
3
- Version: 0.3.2
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):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyTransportNSWv2
3
- Version: 0.3.2
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):
@@ -1 +1,2 @@
1
1
  gtfs-realtime-bindings
2
+ requests
@@ -19,9 +19,21 @@ The source API details can be found here: https://opendata.transport.nsw.gov.au/
19
19
  ```python
20
20
  .get_trip(origin_stop_id, destination_stop_id, api_key, [trip_wait_time = 0], [transport_type = 0])
21
21
  ```
22
-
23
22
  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.
24
23
 
24
+ ### transport_type filters
25
+ ```
26
+ 1: Train
27
+ 4: Light rail
28
+ 5: Bus
29
+ 7: Coach
30
+ 9: Ferry
31
+ 11: School bus
32
+ 99: Walk
33
+ 100: Walk
34
+ 107: Cycle
35
+ ```
36
+
25
37
  ### Sample Code
26
38
 
27
39
  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):
@@ -157,7 +157,7 @@ class TransportNSW(object):
157
157
  origin_name = origin['name']
158
158
  origin_departure_time = origin['departureTimeEstimated']
159
159
 
160
- # How long until it leaves?
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
- if leg_class == legtype or legtype == 0:
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
- if leg_class == legtype or legtype == 0:
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
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="PyTransportNSWv2",
8
- version="0.3.2",
8
+ version="0.3.4",
9
9
  author="andystewart999",
10
10
  description="Get detailed per-trip transport information from TransportNSW",
11
11
  long_description=long_description,
@@ -14,6 +14,7 @@ setuptools.setup(
14
14
  packages=setuptools.find_packages(),
15
15
  install_requires=[
16
16
  'gtfs-realtime-bindings',
17
+ 'requests'
17
18
  ],
18
19
  classifiers=[
19
20
  "Programming Language :: Python :: 3",