PyTransportNSWv2 2.0.4__tar.gz → 2.0.5__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.4 → PyTransportNSWv2-2.0.5}/PKG-INFO +1 -1
- {PyTransportNSWv2-2.0.4 → PyTransportNSWv2-2.0.5}/PyTransportNSWv2.egg-info/PKG-INFO +1 -1
- {PyTransportNSWv2-2.0.4 → PyTransportNSWv2-2.0.5}/TransportNSWv2/TransportNSWv2.py +32 -8
- {PyTransportNSWv2-2.0.4 → PyTransportNSWv2-2.0.5}/setup.py +1 -1
- {PyTransportNSWv2-2.0.4 → PyTransportNSWv2-2.0.5}/LICENSE +0 -0
- {PyTransportNSWv2-2.0.4 → PyTransportNSWv2-2.0.5}/PyTransportNSWv2.egg-info/SOURCES.txt +0 -0
- {PyTransportNSWv2-2.0.4 → PyTransportNSWv2-2.0.5}/PyTransportNSWv2.egg-info/TransportNSWv2.py +0 -0
- {PyTransportNSWv2-2.0.4 → PyTransportNSWv2-2.0.5}/PyTransportNSWv2.egg-info/dependency_links.txt +0 -0
- {PyTransportNSWv2-2.0.4 → PyTransportNSWv2-2.0.5}/PyTransportNSWv2.egg-info/requires.txt +0 -0
- {PyTransportNSWv2-2.0.4 → PyTransportNSWv2-2.0.5}/PyTransportNSWv2.egg-info/top_level.txt +0 -0
- {PyTransportNSWv2-2.0.4 → PyTransportNSWv2-2.0.5}/README.md +0 -0
- {PyTransportNSWv2-2.0.4 → PyTransportNSWv2-2.0.5}/TransportNSWv2/__init__.py +0 -0
- {PyTransportNSWv2-2.0.4 → PyTransportNSWv2-2.0.5}/setup.cfg +0 -0
@@ -42,6 +42,7 @@ ATTR_DESTINATION_LINE_NAME = 'destination_line_name'
|
|
42
42
|
ATTR_DESTINATION_LINE_NAME_SHORT = 'destination_line_name_short'
|
43
43
|
|
44
44
|
ATTR_CHANGES = 'changes'
|
45
|
+
ATTR_CHANGES_LIST = 'changes_list'
|
45
46
|
|
46
47
|
ATTR_ORIGIN_OCCUPANCY = 'origin_occupancy'
|
47
48
|
ATTR_DESTINATION_OCCUPANCY = 'destination_occupancy'
|
@@ -84,6 +85,7 @@ class TransportNSWv2(object):
|
|
84
85
|
ATTR_DESTINATION_LINE_NAME : 'n/a',
|
85
86
|
ATTR_DESTINATION_LINE_NAME_SHORT : 'n/a',
|
86
87
|
ATTR_CHANGES : 'n/a',
|
88
|
+
ATTR_CHANGES_LIST: [],
|
87
89
|
ATTR_ORIGIN_OCCUPANCY: 'n/a',
|
88
90
|
ATTR_DESTINATION_OCCUPANCY: 'n/a',
|
89
91
|
ATTR_ORIGIN_REAL_TIME_TRIP_ID : 'n/a',
|
@@ -298,7 +300,7 @@ class TransportNSWv2(object):
|
|
298
300
|
|
299
301
|
for current_journey_index in range (0, retrieved_journeys, 1):
|
300
302
|
# Look for a trip with a matching transport type filter in at least one of its legs. Either ANY, or the first leg, depending on how strict we're being
|
301
|
-
legs, next_journey_index, first_leg, last_leg, changes = self._find_next_journey(result['journeys'], current_journey_index, origin_transport_type, destination_transport_type, strict_transport_type, route_filter)
|
303
|
+
legs, next_journey_index, first_leg, last_leg, changes, changes_list = self._find_next_journey(result['journeys'], current_journey_index, origin_transport_type, destination_transport_type, strict_transport_type, route_filter)
|
302
304
|
|
303
305
|
if legs is None:
|
304
306
|
# An empty journey that didn't meet the criteria - which means all the valid journeys have been found already
|
@@ -413,6 +415,7 @@ class TransportNSWv2(object):
|
|
413
415
|
ATTR_DESTINATION_LINE_NAME : destination_line_name,
|
414
416
|
ATTR_DESTINATION_LINE_NAME_SHORT : destination_line_name_short,
|
415
417
|
ATTR_CHANGES: changes,
|
418
|
+
ATTR_CHANGES_LIST: changes_list,
|
416
419
|
ATTR_ORIGIN_OCCUPANCY: origin_occupancy,
|
417
420
|
ATTR_DESTINATION_OCCUPANCY: destination_occupancy,
|
418
421
|
ATTR_ORIGIN_REAL_TIME_TRIP_ID: origin_realtimetripid,
|
@@ -461,13 +464,13 @@ class TransportNSWv2(object):
|
|
461
464
|
destination_leg = self._find_last_leg(journey['legs'], destination_transport_type, strict)
|
462
465
|
|
463
466
|
if origin_leg is not None and destination_leg is not None:
|
464
|
-
changes = self._find_changes(journey['legs'], origin_leg, destination_leg)
|
465
|
-
return journey['legs'], journey_index + 1, origin_leg, destination_leg, changes
|
467
|
+
changes, changes_list = self._find_changes(journey['legs'], origin_leg, destination_leg)
|
468
|
+
return journey['legs'], journey_index + 1, origin_leg, destination_leg, changes, changes_list
|
466
469
|
else:
|
467
|
-
return None, None, None, None, None
|
470
|
+
return None, None, None, None, None, None
|
468
471
|
|
469
472
|
# Hmm, we didn't find one
|
470
|
-
return None, None, None, None, None
|
473
|
+
return None, None, None, None, None, None
|
471
474
|
|
472
475
|
|
473
476
|
def _find_first_leg(self, legs, transport_type, strict, route_filter):
|
@@ -527,11 +530,13 @@ class TransportNSWv2(object):
|
|
527
530
|
|
528
531
|
def _find_changes(self, legs, origin_leg, destination_leg):
|
529
532
|
# Find out how often we have to change. Immediately return 0 if the origin and destination legs are the same
|
533
|
+
changes_list = []
|
530
534
|
if origin_leg == destination_leg:
|
531
|
-
return 0
|
535
|
+
return 0, changes_dict
|
532
536
|
|
533
537
|
# Count the changes, each time we hit new non-walking leg is considered to be a change
|
534
538
|
changes = 0
|
539
|
+
last_change =''
|
535
540
|
bInJourney = False
|
536
541
|
|
537
542
|
for leg in legs:
|
@@ -539,17 +544,36 @@ class TransportNSWv2(object):
|
|
539
544
|
# We're in the journey so start capturing changes
|
540
545
|
bInJourney = True
|
541
546
|
|
547
|
+
# Capture the destination, it's the first change. From now on we capture both the origin and the destination until we hit the final leg, in which we only capture the origin
|
548
|
+
last_change = leg['destination']['disassembledName']
|
549
|
+
changes_list.append(last_change)
|
550
|
+
|
542
551
|
elif bInJourney:
|
543
552
|
leg_class = leg['transportation']['product']['class']
|
544
553
|
if leg_class < 99:
|
545
554
|
if leg != destination_leg:
|
546
555
|
changes += 1
|
547
556
|
|
557
|
+
# Also capture the origin and destination as a change, unless it's the same platform or stop as the last one
|
558
|
+
new_change_origin = leg['origin']['disassembledName']
|
559
|
+
new_change_destination = leg['destination']['disassembledName']
|
560
|
+
|
561
|
+
if new_change_origin != last_change:
|
562
|
+
changes_list.append(new_change_origin)
|
563
|
+
changes_list.append(new_change_destination)
|
564
|
+
|
565
|
+
last_change = new_change_destination
|
566
|
+
|
548
567
|
if leg == destination_leg:
|
549
|
-
|
568
|
+
# Capture the last change int he dictionary, again as long as it isn't the same as the previous change location
|
569
|
+
new_change_origin = leg['origin']['disassembledName']
|
570
|
+
if new_change_origin != last_change:
|
571
|
+
changes_list.append(new_change_origin)
|
572
|
+
|
573
|
+
return changes, changes_list
|
550
574
|
|
551
575
|
# We should never get here!
|
552
|
-
return 999
|
576
|
+
return 999, {}
|
553
577
|
|
554
578
|
|
555
579
|
def _find_alerts(self, legs, priority_filter, alert_type):
|
@@ -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.5",
|
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.4 → PyTransportNSWv2-2.0.5}/PyTransportNSWv2.egg-info/TransportNSWv2.py
RENAMED
File without changes
|
{PyTransportNSWv2-2.0.4 → PyTransportNSWv2-2.0.5}/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
|