PyTransportNSWv2 2.0.5__tar.gz → 2.0.7__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: 2.0.5
3
+ Version: 2.0.7
4
4
  Summary: Get detailed per-trip transport information from TransportNSW
5
5
  Home-page: https://github.com/andystewart999/TransportNSW
6
6
  Author: andystewart999
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyTransportNSWv2
3
- Version: 2.0.5
3
+ Version: 2.0.7
4
4
  Summary: Get detailed per-trip transport information from TransportNSW
5
5
  Home-page: https://github.com/andystewart999/TransportNSW
6
6
  Author: andystewart999
@@ -15,6 +15,10 @@ import time
15
15
  # Global API variable
16
16
  api_calls = 0
17
17
 
18
+ def reset_api_counter():
19
+ global api_calls
20
+ api_calls = 0
21
+
18
22
  def increment_api_counter(source):
19
23
  global api_calls
20
24
  api_calls += 1
@@ -115,6 +119,7 @@ class TransportNSWv2(object):
115
119
  stop_list = []
116
120
  skip_api_calls = False
117
121
 
122
+
118
123
  try:
119
124
  for stop in stops:
120
125
  url = \
@@ -200,7 +205,7 @@ class TransportNSWv2(object):
200
205
 
201
206
  """Get the latest data from Transport NSW."""
202
207
  fmt = '%Y-%m-%dT%H:%M:%SZ'
203
- api_calls = 0
208
+ reset_api_counter()
204
209
 
205
210
  route_filter = route_filter.lower()
206
211
  include_alerts = include_alerts.lower()
@@ -532,7 +537,7 @@ class TransportNSWv2(object):
532
537
  # Find out how often we have to change. Immediately return 0 if the origin and destination legs are the same
533
538
  changes_list = []
534
539
  if origin_leg == destination_leg:
535
- return 0, changes_dict
540
+ return 0, changes_list
536
541
 
537
542
  # Count the changes, each time we hit new non-walking leg is considered to be a change
538
543
  changes = 0
@@ -551,25 +556,21 @@ class TransportNSWv2(object):
551
556
  elif bInJourney:
552
557
  leg_class = leg['transportation']['product']['class']
553
558
  if leg_class < 99:
554
- if leg != destination_leg:
555
- changes += 1
559
+ changes += 1
556
560
 
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']
561
+ # Also capture the origin and destination as a change, unless it's the same platform or stop as the last one
562
+ new_change_origin = leg['origin']['disassembledName']
563
+ new_change_destination = leg['destination']['disassembledName']
560
564
 
561
- if new_change_origin != last_change:
562
- changes_list.append(new_change_origin)
563
- changes_list.append(new_change_destination)
565
+ if new_change_origin != last_change:
566
+ changes_list.append(new_change_origin)
564
567
 
568
+ if leg != destination_leg:
569
+ changes_list.append(new_change_destination)
565
570
  last_change = new_change_destination
566
571
 
567
572
  if leg == destination_leg:
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
+ # We've finished looking for changes
573
574
  return changes, changes_list
574
575
 
575
576
  # We should never get here!
@@ -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.5",
8
+ version="2.0.7",
9
9
  author="andystewart999",
10
10
  author_email="andy.stewart@live.com",
11
11
  description="Get detailed per-trip transport information from TransportNSW",