From 3a88dc38ca122eba97192dba3aad30f3bd3e3081 Mon Sep 17 00:00:00 2001 From: Miguel Pires Date: Mon, 20 Nov 2023 16:57:43 +0000 Subject: [PATCH] release-tools: fix handling of NEWS.md items Signed-off-by: Miguel Pires --- release-tools/changelog.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/release-tools/changelog.py b/release-tools/changelog.py index 1ede4299afd..b33da57467d 100755 --- a/release-tools/changelog.py +++ b/release-tools/changelog.py @@ -9,7 +9,7 @@ import textwrap from typing import NamedTuple -from bs4 import BeautifulSoup +from bs4 import BeautifulSoup, NavigableString, Tag import debian.changelog @@ -218,10 +218,18 @@ def read_changelogs_news_md(changelog: io.TextIOWrapper, new_version: str): new_changelog = [] wrapper = textwrap.TextWrapper(initial_indent=" - ", subsequent_indent=" ", width=72) for elm in soup.ul.children: - if not elm.text.strip(): + if type(elm) is Tag: + text = elm.text + elif type(elm) is NavigableString: + text = elm + else: + raise RuntimeError(f'expected list item as Tag or NavigableString but got "{type(elm)}"') + + if not text.strip(): continue + # li can be multiline, concat them - ch_entry = " ".join([line.strip() for line in elm.text.split("\n")]) + ch_entry = " ".join([line.strip() for line in text.split("\n")]) # and wrap again but this time the Debian/Ubuntu way new_changelog.append("\n".join(wrapper.wrap(ch_entry))) new_changelog_str = "\n".join(new_changelog)