Skip to content

Commit 2ba3651

Browse files
committed
Put manifest files by to year/year-month/ dirs
1 parent f58ebf0 commit 2ba3651

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

tagging/update_wiki.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,34 @@
99
LOGGER = logging.getLogger(__name__)
1010

1111

12-
def update_home_wiki_page(wiki_dir: Path, month: str) -> None:
12+
def update_home_wiki_page(wiki_dir: Path, year_month: str) -> None:
1313
TABLE_BEGINNING = """\
1414
| Month |
1515
| ---------------------- |
1616
"""
1717
wiki_home_file = wiki_dir / "Home.md"
1818
wiki_home_content = wiki_home_file.read_text()
19-
month_line = f"| [`{month}`](./{month}) |\n"
20-
if month_line not in wiki_home_content:
19+
year_month_line = f"| [`{year_month}`](./{year_month}) |\n"
20+
if year_month_line not in wiki_home_content:
2121
assert TABLE_BEGINNING in wiki_home_content
2222
wiki_home_content = wiki_home_content.replace(
23-
TABLE_BEGINNING, TABLE_BEGINNING + month_line
23+
TABLE_BEGINNING, TABLE_BEGINNING + year_month_line
2424
)
2525
wiki_home_file.write_text(wiki_home_content)
26-
LOGGER.info(f"Updated wiki home page with month: {month}")
26+
LOGGER.info(f"Updated wiki home page with month: {year_month}")
2727

2828

2929
def update_monthly_wiki_page(
30-
wiki_dir: Path, month: str, build_history_line: str
30+
wiki_dir: Path, year_month: str, build_history_line: str
3131
) -> None:
3232
MONTHLY_PAGE_HEADER = f"""\
33-
# Images built during {month}
33+
# Images built during {year_month}
3434
3535
| Date | Image | Links |
3636
| - | - | - |
3737
"""
38-
monthly_page = wiki_dir / "monthly-files" / (month + ".md")
38+
year = year_month[:4]
39+
monthly_page = wiki_dir / "monthly-files" / year / (year_month + ".md")
3940
if not monthly_page.exists():
4041
monthly_page.write_text(MONTHLY_PAGE_HEADER)
4142
LOGGER.info(f"Created monthly page: {monthly_page.relative_to(wiki_dir)}")
@@ -62,7 +63,7 @@ def get_manifest_timestamp(manifest_file: Path) -> str:
6263
return timestamp
6364

6465

65-
def get_manifest_month(manifest_file: Path) -> str:
66+
def get_manifest_year_month(manifest_file: Path) -> str:
6667
return get_manifest_timestamp(manifest_file)[:7]
6768

6869

@@ -85,8 +86,9 @@ def update_wiki(wiki_dir: Path, hist_lines_dir: Path, manifests_dir: Path) -> No
8586
manifest_files = list(manifests_dir.rglob("*.md"))
8687
assert manifest_files, "expected to have some manifest files"
8788
for manifest_file in manifest_files:
88-
month = get_manifest_month(manifest_file)
89-
copy_to = wiki_dir / "manifests" / month / manifest_file.name
89+
year_month = get_manifest_year_month(manifest_file)
90+
year = year_month[:4]
91+
copy_to = wiki_dir / "manifests" / year / year_month / manifest_file.name
9092
copy_to.parent.mkdir(exist_ok=True)
9193
shutil.copy(manifest_file, copy_to)
9294
LOGGER.info(f"Added manifest file: {copy_to.relative_to(wiki_dir)}")
@@ -96,9 +98,9 @@ def update_wiki(wiki_dir: Path, hist_lines_dir: Path, manifests_dir: Path) -> No
9698
for build_history_line_file in build_history_line_files:
9799
build_history_line = build_history_line_file.read_text()
98100
assert build_history_line.startswith("| `")
99-
month = build_history_line[3:10]
100-
update_home_wiki_page(wiki_dir, month)
101-
update_monthly_wiki_page(wiki_dir, month, build_history_line)
101+
year_month = build_history_line[3:10]
102+
update_home_wiki_page(wiki_dir, year_month)
103+
update_monthly_wiki_page(wiki_dir, year_month, build_history_line)
102104

103105
remove_old_manifests(wiki_dir)
104106

0 commit comments

Comments
 (0)