in check-release-notes/main.py [0:0]
def get_todays_release_note(rss_url):
"""
Parses a product release notes RSS feed and returns the latest release note.
Args:
rss_url (str): The URL of the RSS feed.
Returns:
str: The title and description of the latest release note, or None if an error occurs.
"""
try:
response = requests.get(rss_url)
response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
soup = BeautifulSoup(response.content, "xml")
product = re.sub(
" - release notes", "", soup.find("title").contents[0], flags=re.IGNORECASE
)
updated = soup.find("updated").contents[0]
item = soup.find("entry")
if item:
title = item.find("title").contents[0]
release_note = item.find("content").contents[0]
release_note = remove_libraries(release_note)
link = item.find("link")["href"]
# Parse the updated date of the release note
updated_date = datetime.strptime(updated.split("T")[0], "%Y-%m-%d").date()
today_date = (
datetime.now()
.astimezone(timezone("US/Eastern"))
.replace(second=0, minute=0, hour=0, microsecond=0)
.date()
)
is_updated_today = updated_date == today_date
if is_updated_today:
return dict(
product=product,
date=updated_date.strftime("%B %d, %Y"),
link=link,
html=release_note,
rss_url=rss_url,
)
return None
except requests.exceptions.RequestException as e:
print(f"Error fetching {rss_url}: {e}")
return None
except AttributeError as e:
print(f"Error parsing {rss_url}: {e}")
return None
except Exception as e:
print(f"An unexpected error occurred while fetching {rss_url}: {e}")
return None