in check-release-notes/main.py [0:0]
def get_new_release_note_subsections(latest_release_note, stored_release_note):
"""
Get the new release note subsections by comparing the new release note with the stored release note.
Subsections are defined as any section that starts with <h3> header.
Args:
new_release_note: The new release note
stored_release_note: The stored release note
Returns:
The new release note subsections
"""
latest_release_note_subsections_html = re.split(
r"\<h3\>.*?\<\/h3\>", latest_release_note.get("html")
)[1:]
latest_release_note_subsections_text_only = [
BeautifulSoup(html, "html.parser").get_text()
for html in latest_release_note_subsections_html
]
latest_release_note_subsections_headers = re.findall(
r"<h3>(.*)?</h3>", latest_release_note.get("html")
)
stored_release_note_subsections_html = re.split(
r"\<h3\>.*?\<\/h3\>", stored_release_note.get("html")
)[1:]
stored_release_note_subsections_text_only = [
BeautifulSoup(html, "html.parser").get_text()
for html in stored_release_note_subsections_html
]
stored_release_note_subsections_headers = re.findall(
r"<h3>(.*)?</h3>", stored_release_note.get("html")
)
# Get only new subsections from the latest release note
new_release_notes_subsections = ""
for index, subsection_text in enumerate(latest_release_note_subsections_text_only):
if subsection_text not in stored_release_note_subsections_text_only:
new_release_notes_subsections += f"<h3>{latest_release_note_subsections_headers[index]}</h3>{latest_release_note_subsections_html[index]}"
latest_release_note["html"] = new_release_notes_subsections
return latest_release_note