PyTransportNSWv2 0.8.6__tar.gz → 0.8.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: 0.8.6
3
+ Version: 0.8.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
@@ -148,7 +148,7 @@ Description: # TransportNSWv2
148
148
  Also note that the 'transport_type' filter, if present, only makes sure that at least **one** leg of the journey includes that transport type unless ```strict_transport_type``` is True, in which case the **first** leg must be of the requested type to be returned.
149
149
 
150
150
  ### Rate limits ###
151
- By default the TransportNSW API allows each API key to make 60,000 calls in a day and up to 5 calls per second. Usually this wouldn't be an issue but if you're requesting real-time location data for buses, because I haven't found an elegant way to map the bus route to the correct API URL (and there are about 14) it's brute-forcing it by iterating through ALL the possible URLs until it finds the appropriate journey or it runs out of URLs. From version 0.8.2 I've added in a 0.5 second delay between loops until I can find a better approach.
151
+ By default the TransportNSW API allows each API key to make 60,000 calls in a day and up to 5 calls per second. From version 0.8.7 I found a TransportNSW-maintained CSV that contains mappings of bus agency IDs to URLs so I'm using that, plus adding in a 0.75 second delay between API calls.
152
152
 
153
153
  ## Thank you
154
154
  Thank you Dav0815 for your TransportNSW library that the vast majority of this fork is based on. I couldn't have done it without you!
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyTransportNSWv2
3
- Version: 0.8.6
3
+ Version: 0.8.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
@@ -148,7 +148,7 @@ Description: # TransportNSWv2
148
148
  Also note that the 'transport_type' filter, if present, only makes sure that at least **one** leg of the journey includes that transport type unless ```strict_transport_type``` is True, in which case the **first** leg must be of the requested type to be returned.
149
149
 
150
150
  ### Rate limits ###
151
- By default the TransportNSW API allows each API key to make 60,000 calls in a day and up to 5 calls per second. Usually this wouldn't be an issue but if you're requesting real-time location data for buses, because I haven't found an elegant way to map the bus route to the correct API URL (and there are about 14) it's brute-forcing it by iterating through ALL the possible URLs until it finds the appropriate journey or it runs out of URLs. From version 0.8.2 I've added in a 0.5 second delay between loops until I can find a better approach.
151
+ By default the TransportNSW API allows each API key to make 60,000 calls in a day and up to 5 calls per second. From version 0.8.7 I found a TransportNSW-maintained CSV that contains mappings of bus agency IDs to URLs so I'm using that, plus adding in a 0.75 second delay between API calls.
152
152
 
153
153
  ## Thank you
154
154
  Thank you Dav0815 for your TransportNSW library that the vast majority of this fork is based on. I couldn't have done it without you!
@@ -140,7 +140,7 @@ Note also that the origin and destination details are just that - information ab
140
140
  Also note that the 'transport_type' filter, if present, only makes sure that at least **one** leg of the journey includes that transport type unless ```strict_transport_type``` is True, in which case the **first** leg must be of the requested type to be returned.
141
141
 
142
142
  ### Rate limits ###
143
- By default the TransportNSW API allows each API key to make 60,000 calls in a day and up to 5 calls per second. Usually this wouldn't be an issue but if you're requesting real-time location data for buses, because I haven't found an elegant way to map the bus route to the correct API URL (and there are about 14) it's brute-forcing it by iterating through ALL the possible URLs until it finds the appropriate journey or it runs out of URLs. From version 0.8.2 I've added in a 0.5 second delay between loops until I can find a better approach.
143
+ By default the TransportNSW API allows each API key to make 60,000 calls in a day and up to 5 calls per second. From version 0.8.7 I found a TransportNSW-maintained CSV that contains mappings of bus agency IDs to URLs so I'm using that, plus adding in a 0.75 second delay between API calls.
144
144
 
145
145
  ## Thank you
146
146
  Thank you Dav0815 for your TransportNSW library that the vast majority of this fork is based on. I couldn't have done it without you!
@@ -115,7 +115,7 @@ class TransportNSWv2(object):
115
115
 
116
116
  # Send the query and return an error if something goes wrong
117
117
  try:
118
- response = requests.get(url, headers=header, timeout=20)
118
+ response = requests.get(url, headers=header, timeout=5)
119
119
  except Exception as ex:
120
120
  logger.error("Network or Timeout error when calling /v1/tp/stop_finder API")
121
121
  return None
@@ -157,7 +157,7 @@ class TransportNSWv2(object):
157
157
  # Send the query and return an error if something goes wrong
158
158
  # Otherwise store the response
159
159
  try:
160
- response = requests.get(url, headers=header, timeout=20)
160
+ response = requests.get(url, headers=header, timeout=10)
161
161
  except:
162
162
  logger.error("Network or timeout error")
163
163
  return None
@@ -527,13 +527,14 @@ class TransportNSWv2(object):
527
527
  Map the journey mode to the proper modifier URL. If the mode is Bus, Coach or School bus then use the agency ID to invoke the GTFS datastore search API
528
528
  which will give us the appropriate URL to call later - we still have to do light rail the old-fashioned, brute-force way though
529
529
  """
530
+
530
531
  if mode in ["Bus", "Coach", "School bus"]:
531
532
  # Use the API to determine the appropriate URL
532
533
  url = "https://opendata.transport.nsw.gov.au/data/api/action/datastore_search?resource_id=30b850b7-f439-4e30-8072-e07ef62a2a36&filters={%22For%20Realtime%20GTFS%20agency_id%22:%22" + agencyid + "%22}&limit=1"
533
534
 
534
535
  # Send the query and return an error if something goes wrong
535
536
  try:
536
- response = requests.get(url, timeout=20)
537
+ response = requests.get(url, timeout=5)
537
538
  except Exception as ex:
538
539
  logger.error("Error " + str(ex) + " querying GTFS URL datastore")
539
540
  return None
@@ -555,17 +556,16 @@ class TransportNSWv2(object):
555
556
  return None
556
557
 
557
558
  bus_list = ["/" + mode_path]
558
-
559
- url_options = {
560
- "Train" : ["/sydneytrains"],
561
- "Metro" : ["/metro"],
562
- "Light rail" : ["/lightrail/innerwest", "/lightrail/cbdandsoutheast", "/lightrail/newcastle"],
563
- "Bus" : bus_list,
564
- "Coach" : bus_list,
565
- "Ferry" : ["/ferries/sydneyferries"],
566
- "School bus" : bus_list
567
- }
568
- return url_options.get(mode, None)
559
+ return bus_list
560
+ else:
561
+ # Handle the other modes
562
+ url_options = {
563
+ "Train" : ["/sydneytrains"],
564
+ "Metro" : ["/metro"],
565
+ "Light rail" : ["/lightrail/innerwest", "/lightrail/cbdandsoutheast", "/lightrail/newcastle"],
566
+ "Ferry" : ["/ferries/sydneyferries"]
567
+ }
568
+ return url_options.get(mode, None)
569
569
 
570
570
 
571
571
  def get_due(self, estimated):
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="PyTransportNSWv2",
8
- version="0.8.6",
8
+ version="0.8.7",
9
9
  author="andystewart999",
10
10
  author_email="andy.stewart@live.com",
11
11
  description="Get detailed per-trip transport information from TransportNSW",