From 209a7464f4044665c59b3766cbb09f059ba9b7f4 Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Sun, 29 Dec 2024 02:36:27 +0500 Subject: [PATCH] Group build manifests by year --- tagging/update_wiki.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/tagging/update_wiki.py b/tagging/update_wiki.py index 4ce091d8fe..3ae98da2be 100755 --- a/tagging/update_wiki.py +++ b/tagging/update_wiki.py @@ -10,21 +10,36 @@ def update_home_wiki_page(wiki_dir: Path, year_month: str) -> None: - TABLE_BEGINNING = """\ + YEAR_MONTHLY_TABLES = "\n" + + TABLE_HEADER = """\ | Month | | ---------------------- | """ + wiki_home_file = wiki_dir / "Home.md" wiki_home_content = wiki_home_file.read_text() + + year = year_month[:4] + year_header = f"## {year}\n" + if year_header not in wiki_home_content: + assert YEAR_MONTHLY_TABLES in wiki_home_content + wiki_home_content = wiki_home_content.replace( + YEAR_MONTHLY_TABLES, + YEAR_MONTHLY_TABLES + f"\n{year_header}\n{TABLE_HEADER}", + ) + LOGGER.info(f"Updated wiki home page with year header for year: {year}") + year_month_line = f"| [`{year_month}`](./{year_month}) |\n" if year_month_line not in wiki_home_content: - assert TABLE_BEGINNING in wiki_home_content + assert TABLE_HEADER in wiki_home_content wiki_home_content = wiki_home_content.replace( - TABLE_BEGINNING, TABLE_BEGINNING + year_month_line + TABLE_HEADER, TABLE_HEADER + year_month_line ) - wiki_home_file.write_text(wiki_home_content) LOGGER.info(f"Updated wiki home page with month: {year_month}") + wiki_home_file.write_text(wiki_home_content) + def update_monthly_wiki_page( wiki_dir: Path, year_month: str, build_history_line: str