9
9
LOGGER = logging .getLogger (__name__ )
10
10
11
11
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 :
13
13
TABLE_BEGINNING = """\
14
14
| Month |
15
15
| ---------------------- |
16
16
"""
17
17
wiki_home_file = wiki_dir / "Home.md"
18
18
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 :
21
21
assert TABLE_BEGINNING in wiki_home_content
22
22
wiki_home_content = wiki_home_content .replace (
23
- TABLE_BEGINNING , TABLE_BEGINNING + month_line
23
+ TABLE_BEGINNING , TABLE_BEGINNING + year_month_line
24
24
)
25
25
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 } " )
27
27
28
28
29
29
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
31
31
) -> None :
32
32
MONTHLY_PAGE_HEADER = f"""\
33
- # Images built during { month }
33
+ # Images built during { year_month }
34
34
35
35
| Date | Image | Links |
36
36
| - | - | - |
37
37
"""
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" )
39
40
if not monthly_page .exists ():
40
41
monthly_page .write_text (MONTHLY_PAGE_HEADER )
41
42
LOGGER .info (f"Created monthly page: { monthly_page .relative_to (wiki_dir )} " )
@@ -62,7 +63,7 @@ def get_manifest_timestamp(manifest_file: Path) -> str:
62
63
return timestamp
63
64
64
65
65
- def get_manifest_month (manifest_file : Path ) -> str :
66
+ def get_manifest_year_month (manifest_file : Path ) -> str :
66
67
return get_manifest_timestamp (manifest_file )[:7 ]
67
68
68
69
@@ -85,8 +86,9 @@ def update_wiki(wiki_dir: Path, hist_lines_dir: Path, manifests_dir: Path) -> No
85
86
manifest_files = list (manifests_dir .rglob ("*.md" ))
86
87
assert manifest_files , "expected to have some manifest files"
87
88
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
90
92
copy_to .parent .mkdir (exist_ok = True )
91
93
shutil .copy (manifest_file , copy_to )
92
94
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
96
98
for build_history_line_file in build_history_line_files :
97
99
build_history_line = build_history_line_file .read_text ()
98
100
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 )
102
104
103
105
remove_old_manifests (wiki_dir )
104
106
0 commit comments