14
14
15
15
LOGGER = logging .getLogger (__name__ )
16
16
17
- YEAR_TABLE_HEADER = """\
18
- ## {year}
19
-
20
- | Month | Builds | Images | Commits |
21
- | ---------------------- | ------ | ------ | ------- |
22
- """
23
17
24
-
25
- def build_monthly_table_line (year_month_file : Path ) -> str :
18
+ def calculate_monthly_stat (year_month_file : Path ) -> tuple [int , int , int ]:
26
19
year_month_file_content = year_month_file .read_text ()
27
- images = year_month_file_content . count ( "Build manifest" )
20
+
28
21
builds = sum (
29
22
"jupyter/base-notebook" in line and "aarch64" not in line
30
23
for line in year_month_file_content .split ("\n " )
31
24
)
25
+
26
+ images = year_month_file_content .count ("Build manifest" )
27
+
32
28
year_month = year_month_file .stem
33
29
current_month = datetime .date (
34
30
year = int (year_month [:4 ]), month = int (year_month [5 :]), day = 1
@@ -50,7 +46,7 @@ def build_monthly_table_line(year_month_file: Path) -> str:
50
46
future .wait ()
51
47
commits = len (future .stdout .splitlines ())
52
48
53
- return f"| [` { year_month } `](./ { year_month } ) | { builds : <6 } | { images : <6 } | { commits : <7 } | \n "
49
+ return builds , images , commits
54
50
55
51
56
52
def regenerate_home_wiki_page (wiki_dir : Path ) -> None :
@@ -64,10 +60,26 @@ def regenerate_home_wiki_page(wiki_dir: Path) -> None:
64
60
: wiki_home_content .find (YEAR_MONTHLY_TABLES ) + len (YEAR_MONTHLY_TABLES )
65
61
]
66
62
63
+ YEAR_TABLE_HEADER = """\
64
+ ## {year}
65
+
66
+ | Month | Builds | Images | Commits |
67
+ | ---------------------- | ------ | ------ | ------- |
68
+ """
69
+
67
70
for year_dir in sorted ((wiki_dir / "monthly-files" ).glob ("*" ), reverse = True ):
68
71
wiki_home_content += "\n " + YEAR_TABLE_HEADER .format (year = year_dir .name )
72
+ year_builds , year_images , year_commits = 0 , 0 , 0
69
73
for year_month_file in sorted (year_dir .glob ("*.md" ), reverse = True ):
70
- wiki_home_content += build_monthly_table_line (year_month_file )
74
+ builds , images , commits = calculate_monthly_stat (year_month_file )
75
+ year_builds += builds
76
+ year_images += images
77
+ year_commits += commits
78
+ year_month = year_month_file .stem
79
+ monthly_line = f"| [`{ year_month } `](./{ year_month } ) | { builds : <6} | { images : <6} | { commits : <7} |\n "
80
+ wiki_home_content += monthly_line
81
+ year_total_line = f"| **Total** | { year_builds : <6} | { year_images : <6} | { year_commits : <7} |\n "
82
+ wiki_home_content += year_total_line
71
83
72
84
wiki_home_file .write_text (wiki_home_content )
73
85
LOGGER .info ("Updated Home page" )
0 commit comments