From 5cba78c46ba9efc02a5b159bf1375e3f9d4b50a5 Mon Sep 17 00:00:00 2001 From: James Bruten <109733895+james-bruten-mo@users.noreply.github.com> Date: Tue, 17 Mar 2026 10:14:39 +0000 Subject: [PATCH 1/7] add option for html output --- gh_review_project/workload.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/gh_review_project/workload.py b/gh_review_project/workload.py index 63748adf..f68f361d 100644 --- a/gh_review_project/workload.py +++ b/gh_review_project/workload.py @@ -144,21 +144,29 @@ def build_table(data: ProjectData, reviewer_list: list, repos: list) -> PrettyTa return table -def print_table(title: str, table: PrettyTable, sortTotal: bool) -> None: +def print_table(title: str, table: PrettyTable, sortTotal: bool, html_output: str = "") -> None: """ Print a pretty table and its title. title: str Title of table to be printed first table: PrettyTable table to be printed """ - print(title) - # table.set_style(TableStyle.MARKDOWN) #requires newer version + table.align["Reviewer"] = "l" if sortTotal: table.sortby = "Total" - print(table) + if not html_output: + print(title) + print(table) + return + + table.format = True + html_table = table.get_html_string() + with open(html_output, "a") as f: + f.write(f"

{title}

") + f.write(html_table) def parse_args(): @@ -192,9 +200,25 @@ def parse_args(): help="Filepath to test data for either capture the project status, " "or use as input data.", ) + parser.add_argument( + "--html", + default="", + help="html file to output table contents to. If not set, an ascii formatted " + "table will be outputted to stdout" + ) args = parser.parse_args() + # If html file provided, then ensure the directory exists and the file is empty + if args.html: + html_path = Path(args.html) + if html_path.is_dir(): + raise ValueError("--html option cannot be a directory") + html_dir = html_path.parent + html_dir.mkdir(parents=True, exist_ok=True) + html_path.unlink(missing_ok=True) + + args.file = Path(args.file) args.file = args.file.expanduser().resolve() @@ -237,7 +261,7 @@ def main(total: bool, test: bool, capture_project: bool, file: Path): # Print tables for name, table in tables.items(): - print_table(name, table, total) + print_table(name, table, total, args.html) if __name__ == "__main__": From 1cbc0b4e6637d82b25419a15e3d55f9f5e37dcd1 Mon Sep 17 00:00:00 2001 From: James Bruten <109733895+james-bruten-mo@users.noreply.github.com> Date: Tue, 17 Mar 2026 10:17:30 +0000 Subject: [PATCH 2/7] format --- gh_review_project/workload.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gh_review_project/workload.py b/gh_review_project/workload.py index f68f361d..9134b64b 100644 --- a/gh_review_project/workload.py +++ b/gh_review_project/workload.py @@ -144,7 +144,9 @@ def build_table(data: ProjectData, reviewer_list: list, repos: list) -> PrettyTa return table -def print_table(title: str, table: PrettyTable, sortTotal: bool, html_output: str = "") -> None: +def print_table( + title: str, table: PrettyTable, sortTotal: bool, html_output: str = "" +) -> None: """ Print a pretty table and its title. @@ -204,7 +206,7 @@ def parse_args(): "--html", default="", help="html file to output table contents to. If not set, an ascii formatted " - "table will be outputted to stdout" + "table will be outputted to stdout", ) args = parser.parse_args() @@ -218,7 +220,6 @@ def parse_args(): html_dir.mkdir(parents=True, exist_ok=True) html_path.unlink(missing_ok=True) - args.file = Path(args.file) args.file = args.file.expanduser().resolve() From 9c082762075271c5fc1b20a4ba406462dd9bcb82 Mon Sep 17 00:00:00 2001 From: James Bruten <109733895+james-bruten-mo@users.noreply.github.com> Date: Tue, 17 Mar 2026 10:52:42 +0000 Subject: [PATCH 3/7] make executable --- gh_review_project/cr_deadline.py | 0 gh_review_project/finish_milestone.py | 0 gh_review_project/set_milestone.py | 0 gh_review_project/workload.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 gh_review_project/cr_deadline.py mode change 100644 => 100755 gh_review_project/finish_milestone.py mode change 100644 => 100755 gh_review_project/set_milestone.py mode change 100644 => 100755 gh_review_project/workload.py diff --git a/gh_review_project/cr_deadline.py b/gh_review_project/cr_deadline.py old mode 100644 new mode 100755 diff --git a/gh_review_project/finish_milestone.py b/gh_review_project/finish_milestone.py old mode 100644 new mode 100755 diff --git a/gh_review_project/set_milestone.py b/gh_review_project/set_milestone.py old mode 100644 new mode 100755 diff --git a/gh_review_project/workload.py b/gh_review_project/workload.py old mode 100644 new mode 100755 From f53e4e67294769217a9c01a51f9d63c95887cb2a Mon Sep 17 00:00:00 2001 From: James Bruten <109733895+james-bruten-mo@users.noreply.github.com> Date: Tue, 17 Mar 2026 10:58:51 +0000 Subject: [PATCH 4/7] add shebang --- gh_review_project/cr_deadline.py | 1 + gh_review_project/finish_milestone.py | 1 + gh_review_project/set_milestone.py | 1 + gh_review_project/workload.py | 1 + 4 files changed, 4 insertions(+) diff --git a/gh_review_project/cr_deadline.py b/gh_review_project/cr_deadline.py index a8f419d2..8f84297e 100755 --- a/gh_review_project/cr_deadline.py +++ b/gh_review_project/cr_deadline.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # ----------------------------------------------------------------------------- # (C) Crown copyright Met Office. All rights reserved. # The file LICENCE, distributed with this code, contains details of the terms diff --git a/gh_review_project/finish_milestone.py b/gh_review_project/finish_milestone.py index 67b5698d..a7c025f7 100755 --- a/gh_review_project/finish_milestone.py +++ b/gh_review_project/finish_milestone.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # ----------------------------------------------------------------------------- # (C) Crown copyright Met Office. All rights reserved. # The file LICENCE, distributed with this code, contains details of the terms diff --git a/gh_review_project/set_milestone.py b/gh_review_project/set_milestone.py index 1995326a..01a2c710 100755 --- a/gh_review_project/set_milestone.py +++ b/gh_review_project/set_milestone.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # ----------------------------------------------------------------------------- # (C) Crown copyright Met Office. All rights reserved. # The file LICENCE, distributed with this code, contains details of the terms diff --git a/gh_review_project/workload.py b/gh_review_project/workload.py index 9134b64b..19da6457 100755 --- a/gh_review_project/workload.py +++ b/gh_review_project/workload.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # ----------------------------------------------------------------------------- # (C) Crown copyright Met Office. All rights reserved. # The file LICENCE, distributed with this code, contains details of the terms From 8b4863b2639089943876d9f329b441ef282671df Mon Sep 17 00:00:00 2001 From: James Bruten <109733895+james-bruten-mo@users.noreply.github.com> Date: Tue, 17 Mar 2026 11:50:54 +0000 Subject: [PATCH 5/7] modify where check is --- gh_review_project/workload.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/gh_review_project/workload.py b/gh_review_project/workload.py index 19da6457..a11560ad 100755 --- a/gh_review_project/workload.py +++ b/gh_review_project/workload.py @@ -165,6 +165,14 @@ def print_table( print(table) return + # Check html path is valid + html_path = Path(args.html) + if html_path.is_dir(): + raise ValueError("--html option cannot be a directory") + html_dir = html_path.parent + html_dir.mkdir(parents=True, exist_ok=True) + html_path.unlink(missing_ok=True) + table.format = True html_table = table.get_html_string() with open(html_output, "a") as f: @@ -212,15 +220,6 @@ def parse_args(): args = parser.parse_args() - # If html file provided, then ensure the directory exists and the file is empty - if args.html: - html_path = Path(args.html) - if html_path.is_dir(): - raise ValueError("--html option cannot be a directory") - html_dir = html_path.parent - html_dir.mkdir(parents=True, exist_ok=True) - html_path.unlink(missing_ok=True) - args.file = Path(args.file) args.file = args.file.expanduser().resolve() From 2b3d419e1abc0c77a050d26c61dd1331f48c0417 Mon Sep 17 00:00:00 2001 From: James Bruten <109733895+james-bruten-mo@users.noreply.github.com> Date: Tue, 17 Mar 2026 12:01:44 +0000 Subject: [PATCH 6/7] another move of checks --- gh_review_project/workload.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/gh_review_project/workload.py b/gh_review_project/workload.py index a11560ad..813539ed 100755 --- a/gh_review_project/workload.py +++ b/gh_review_project/workload.py @@ -165,14 +165,6 @@ def print_table( print(table) return - # Check html path is valid - html_path = Path(args.html) - if html_path.is_dir(): - raise ValueError("--html option cannot be a directory") - html_dir = html_path.parent - html_dir.mkdir(parents=True, exist_ok=True) - html_path.unlink(missing_ok=True) - table.format = True html_table = table.get_html_string() with open(html_output, "a") as f: @@ -261,10 +253,18 @@ def main(total: bool, test: bool, capture_project: bool, file: Path): tables["LFRic"] = build_table(data, reviewers, repo_list) # Print tables + # Check html path is valid + if args.html: + html_path = Path(args.html) + if html_path.is_dir(): + raise ValueError("--html option cannot be a directory") + html_dir = html_path.parent + html_dir.mkdir(parents=True, exist_ok=True) + html_path.unlink(missing_ok=True) + for name, table in tables.items(): print_table(name, table, total, args.html) - if __name__ == "__main__": args = parse_args() main(args.total, args.test, args.capture_project, args.file) From ab3972a6315bf0f31caebd542550baf057cc3e61 Mon Sep 17 00:00:00 2001 From: James Bruten <109733895+james-bruten-mo@users.noreply.github.com> Date: Tue, 24 Mar 2026 09:17:22 +0000 Subject: [PATCH 7/7] format --- gh_review_project/workload.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gh_review_project/workload.py b/gh_review_project/workload.py index 813539ed..0eb4df9c 100755 --- a/gh_review_project/workload.py +++ b/gh_review_project/workload.py @@ -265,6 +265,7 @@ def main(total: bool, test: bool, capture_project: bool, file: Path): for name, table in tables.items(): print_table(name, table, total, args.html) + if __name__ == "__main__": args = parse_args() main(args.total, args.test, args.capture_project, args.file)