PyTransportNSWv2 2.0.2__tar.gz → 2.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-2.0.2 → PyTransportNSWv2-2.0.4}/PKG-INFO +1 -1
- {PyTransportNSWv2-2.0.2 → PyTransportNSWv2-2.0.4}/PyTransportNSWv2.egg-info/PKG-INFO +1 -1
- {PyTransportNSWv2-2.0.2 → PyTransportNSWv2-2.0.4}/TransportNSWv2/TransportNSWv2.py +22 -15
- {PyTransportNSWv2-2.0.2 → PyTransportNSWv2-2.0.4}/setup.py +1 -1
- {PyTransportNSWv2-2.0.2 → PyTransportNSWv2-2.0.4}/LICENSE +0 -0
- {PyTransportNSWv2-2.0.2 → PyTransportNSWv2-2.0.4}/PyTransportNSWv2.egg-info/SOURCES.txt +0 -0
- {PyTransportNSWv2-2.0.2 → PyTransportNSWv2-2.0.4}/PyTransportNSWv2.egg-info/TransportNSWv2.py +0 -0
- {PyTransportNSWv2-2.0.2 → PyTransportNSWv2-2.0.4}/PyTransportNSWv2.egg-info/dependency_links.txt +0 -0
- {PyTransportNSWv2-2.0.2 → PyTransportNSWv2-2.0.4}/PyTransportNSWv2.egg-info/requires.txt +0 -0
- {PyTransportNSWv2-2.0.2 → PyTransportNSWv2-2.0.4}/PyTransportNSWv2.egg-info/top_level.txt +0 -0
- {PyTransportNSWv2-2.0.2 → PyTransportNSWv2-2.0.4}/README.md +0 -0
- {PyTransportNSWv2-2.0.2 → PyTransportNSWv2-2.0.4}/TransportNSWv2/__init__.py +0 -0
- {PyTransportNSWv2-2.0.2 → PyTransportNSWv2-2.0.4}/setup.cfg +0 -0
@@ -198,6 +198,7 @@ class TransportNSWv2(object):
|
|
198
198
|
|
199
199
|
"""Get the latest data from Transport NSW."""
|
200
200
|
fmt = '%Y-%m-%dT%H:%M:%SZ'
|
201
|
+
api_calls = 0
|
201
202
|
|
202
203
|
route_filter = route_filter.lower()
|
203
204
|
include_alerts = include_alerts.lower()
|
@@ -269,7 +270,7 @@ class TransportNSWv2(object):
|
|
269
270
|
raise APIRateLimitExceeded("Error 'API rate limit exceeded' calling trip API for journey {name_origin} to {name_destination}")
|
270
271
|
|
271
272
|
else:
|
272
|
-
raise TripError(f"Error '{str(response.
|
273
|
+
raise TripError(f"Error '{str(response.status_code)}' calling trip API for journey {name_origin} to {name_destination}")
|
273
274
|
|
274
275
|
result = response.json()
|
275
276
|
|
@@ -452,14 +453,16 @@ class TransportNSWv2(object):
|
|
452
453
|
return None, None, None, None, None
|
453
454
|
|
454
455
|
for journey_index in range (start_journey_index, journey_count, 1):
|
455
|
-
|
456
|
+
journey = journeys[journey_index]
|
457
|
+
|
458
|
+
origin_leg = self._find_first_leg(journey['legs'], origin_transport_type, strict, route_filter)
|
456
459
|
|
457
460
|
if origin_leg is not None:
|
458
|
-
destination_leg = self._find_last_leg(
|
461
|
+
destination_leg = self._find_last_leg(journey['legs'], destination_transport_type, strict)
|
459
462
|
|
460
463
|
if origin_leg is not None and destination_leg is not None:
|
461
|
-
changes = self._find_changes(
|
462
|
-
return
|
464
|
+
changes = self._find_changes(journey['legs'], origin_leg, destination_leg)
|
465
|
+
return journey['legs'], journey_index + 1, origin_leg, destination_leg, changes
|
463
466
|
else:
|
464
467
|
return None, None, None, None, None
|
465
468
|
|
@@ -523,24 +526,28 @@ class TransportNSWv2(object):
|
|
523
526
|
|
524
527
|
|
525
528
|
def _find_changes(self, legs, origin_leg, destination_leg):
|
526
|
-
# Find out how often we have to change
|
529
|
+
# Find out how often we have to change. Immediately return 0 if the origin and destination legs are the same
|
530
|
+
if origin_leg == destination_leg:
|
531
|
+
return 0
|
532
|
+
|
533
|
+
# Count the changes, each time we hit new non-walking leg is considered to be a change
|
527
534
|
changes = 0
|
528
535
|
bInJourney = False
|
529
536
|
|
530
537
|
for leg in legs:
|
531
|
-
if leg == destination_leg:
|
532
|
-
# We've found the last leg (which oould be the same as the first leg), stop counting
|
533
|
-
return changes
|
534
|
-
|
535
538
|
if leg == origin_leg:
|
536
|
-
# We'
|
539
|
+
# We're in the journey so start capturing changes
|
537
540
|
bInJourney = True
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
541
|
+
|
542
|
+
elif bInJourney:
|
543
|
+
leg_class = leg['transportation']['product']['class']
|
544
|
+
if leg_class < 99:
|
545
|
+
if leg != destination_leg:
|
542
546
|
changes += 1
|
543
547
|
|
548
|
+
if leg == destination_leg:
|
549
|
+
return changes
|
550
|
+
|
544
551
|
# We should never get here!
|
545
552
|
return 999
|
546
553
|
|
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|
5
5
|
|
6
6
|
setuptools.setup(
|
7
7
|
name="PyTransportNSWv2",
|
8
|
-
version="2.0.
|
8
|
+
version="2.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-2.0.2 → PyTransportNSWv2-2.0.4}/PyTransportNSWv2.egg-info/TransportNSWv2.py
RENAMED
File without changes
|
{PyTransportNSWv2-2.0.2 → PyTransportNSWv2-2.0.4}/PyTransportNSWv2.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|