mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-06-24 05:35:10 +00:00
Fix some IDE warnings, mostly around type safety on the Python side
This commit is contained in:
@@ -21,19 +21,30 @@ class BOTA(HTTPAlertProvider):
|
||||
new_alerts = []
|
||||
# Find the table of upcoming alerts
|
||||
bs = BeautifulSoup(http_response.content.decode(), features="lxml")
|
||||
if not bs.body:
|
||||
return new_alerts
|
||||
div = bs.body.find('div', attrs={'class': 'view-activations-public'})
|
||||
if div:
|
||||
table = div.find('table', attrs={'class': 'views-table'})
|
||||
if table:
|
||||
tbody = table.find('tbody')
|
||||
if not tbody:
|
||||
return new_alerts
|
||||
for row in tbody.find_all('tr'):
|
||||
cells = row.find_all('td')
|
||||
first_cell_text = str(cells[0].find('a').contents[0]).strip()
|
||||
first_cell_anchor = cells[0].find('a') if len(cells) > 0 else None
|
||||
second_cell_anchor = cells[1].find('a') if len(cells) > 1 else None
|
||||
if not first_cell_anchor or not second_cell_anchor:
|
||||
continue
|
||||
first_cell_text = first_cell_anchor.get_text().strip()
|
||||
ref_name = first_cell_text.split(" by ")[0]
|
||||
dx_call = str(cells[1].find('a').contents[0]).strip().upper()
|
||||
dx_call = second_cell_anchor.get_text().strip().upper()
|
||||
|
||||
# Get the date, dealing with the fact we get no year so have to figure out if it's last year or next year
|
||||
date_text = str(cells[2].find('span').contents[0]).strip()
|
||||
date_span = cells[2].find('span') if len(cells) > 2 else None
|
||||
if not date_span:
|
||||
continue
|
||||
date_text = date_span.get_text().strip()
|
||||
date_time = datetime.strptime(date_text, "%d %b - %H:%M UTC").replace(tzinfo=pytz.UTC)
|
||||
date_time = date_time.replace(year=datetime.now(pytz.UTC).year)
|
||||
# If this was more than a day ago, activation is actually next year
|
||||
|
||||
Reference in New Issue
Block a user