42Cummer commited on
Commit
5234669
·
verified ·
1 Parent(s): 27323df

Update app.py

Browse files

i forgot how an hour works

Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -105,8 +105,7 @@ def get_vehicle_destinations(vehicle_numbers):
105
  vehicle_info[vid] = destination
106
 
107
  # Now vehicle_info is a dict mapping vehicle IDs to their info
108
- return vehicle_info # cannot double jsonify!
109
-
110
 
111
  @app.route('/', methods=['GET'])
112
  def health_check():
@@ -186,15 +185,19 @@ def seek():
186
  if minpred_span:
187
  secs_span = minpred_span.find('span', id=re.compile(r'SECS\d+')) # will always exist
188
  secs_value = secs_span.text.strip()
189
- hours_value = 0
190
-
191
- # Check for the presence of an hour indicator
192
- if secs_span.find_next('span') and 'h' in secs_span.find_next('span').text:
193
- hours_value = int(secs_span.find_next('span').text.strip()) if secs_span.find_next('span').text.strip().isdigit() else 0
194
 
195
- # Get the next text node for minutes
196
- next_text = secs_span.find_next(text=True)
197
- minutes_value = int(next_text.strip()) if next_text.strip().isdigit() else 0
 
 
 
 
 
 
 
 
 
198
 
199
  # Convert to total minutes
200
  if secs_value == "0" or secs_value.startswith("!"):
 
105
  vehicle_info[vid] = destination
106
 
107
  # Now vehicle_info is a dict mapping vehicle IDs to their info
108
+ return vehicle_info
 
109
 
110
  @app.route('/', methods=['GET'])
111
  def health_check():
 
185
  if minpred_span:
186
  secs_span = minpred_span.find('span', id=re.compile(r'SECS\d+')) # will always exist
187
  secs_value = secs_span.text.strip()
 
 
 
 
 
188
 
189
+ # Check for the presence of an hour indicator within the same span
190
+ if secs_span.find('span', text='h'):
191
+ # Extract hours from the first content (text before the <span>)
192
+ hours_text = secs_span.contents[0].strip() # Get the text node before the <span>
193
+ hours_value = int(hours_text) if hours_text.isdigit() else 0
194
+
195
+ # Extract minutes from the third content (text after the <span>)
196
+ minutes_text = secs_span.contents[2].strip() # Get the text node after the <span>
197
+ minutes_value = int(minutes_text) if minutes_text.isdigit() else 0
198
+ else:
199
+ hours_value = 0
200
+ minutes_value = int(secs_value) if secs_value.isdigit() else 0
201
 
202
  # Convert to total minutes
203
  if secs_value == "0" or secs_value.startswith("!"):