From 3355e03f85fb431adb084175bafea2d87663f049 Mon Sep 17 00:00:00 2001 From: Oreoluwa Oluwasina Date: Fri, 16 Jan 2026 21:15:46 +0100 Subject: [PATCH 1/2] checks for last entry in the report script --- scripts/3-report/gcs_report.py | 9 ++++++++- scripts/3-report/github_report.py | 10 ++++++++++ scripts/3-report/wikipedia_report.py | 10 ++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/scripts/3-report/gcs_report.py b/scripts/3-report/gcs_report.py index eb9130fe..0003b1cc 100755 --- a/scripts/3-report/gcs_report.py +++ b/scripts/3-report/gcs_report.py @@ -70,6 +70,13 @@ def parse_arguments(): return args +def check_report_completion(args): + last_entry = shared.path_join(PATHS["data_phase"], "gcs_free_culture.png") + if os.path.exists(last_entry) and not args.force: + LOGGER.info(f"{last_entry} already exists. Script completed") + return + + def gcs_intro(args): """ Write Google Custom Search (GCS) introduction. @@ -491,7 +498,7 @@ def main(): args = parse_arguments() shared.paths_log(LOGGER, PATHS) shared.git_fetch_and_merge(args, PATHS["repo"]) - + check_report_completion(args) gcs_intro(args) plot_products(args) plot_tool_status(args) diff --git a/scripts/3-report/github_report.py b/scripts/3-report/github_report.py index 958dcc40..5f220555 100755 --- a/scripts/3-report/github_report.py +++ b/scripts/3-report/github_report.py @@ -73,6 +73,15 @@ def parse_arguments(): return args +def check_report_completion(args): + last_entry = shared.path_join( + PATHS["data_phase"], "github_restriction.png" + ) + if os.path.exists(last_entry) and not args.force: + LOGGER.info(f"{last_entry} already exists. Script completed") + return + + def load_data(args): """ Load the collected data from the CSV file. @@ -243,6 +252,7 @@ def main(): args = parse_arguments() shared.paths_log(LOGGER, PATHS) shared.git_fetch_and_merge(args, PATHS["repo"]) + check_report_completion(args) github_intro(args) plot_totals_by_license_type(args) plot_totals_by_restriction(args) diff --git a/scripts/3-report/wikipedia_report.py b/scripts/3-report/wikipedia_report.py index 9224bcb6..44ca1e91 100755 --- a/scripts/3-report/wikipedia_report.py +++ b/scripts/3-report/wikipedia_report.py @@ -68,6 +68,15 @@ def parse_arguments(): return args +def check_report_completion(args): + last_entry = shared.path_join( + PATHS["data_phase"], "wikipedia_least_language_usage.png" + ) + if os.path.exists(last_entry) and not args.force: + LOGGER.info(f"{last_entry} already exists. Script completed") + return + + def wikipedia_intro(args): """ Write Wikipedia introduction. @@ -261,6 +270,7 @@ def main(): args = parse_arguments() shared.paths_log(LOGGER, PATHS) shared.git_fetch_and_merge(args, PATHS["repo"]) + check_report_completion(args) wikipedia_intro(args) plot_language_representation(args) plot_highest_language_usage(args) From 36fd3aa1aef41cce268f526ed54624c5ea1d0575 Mon Sep 17 00:00:00 2001 From: Oreoluwa Oluwasina Date: Tue, 20 Jan 2026 23:42:08 +0100 Subject: [PATCH 2/2] Made review changes --- scripts/3-report/gcs_report.py | 21 ++++++++++++++++++--- scripts/3-report/github_report.py | 21 ++++++++++++++++++--- scripts/3-report/wikipedia_report.py | 21 ++++++++++++++++++--- 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/scripts/3-report/gcs_report.py b/scripts/3-report/gcs_report.py index 0003b1cc..17884dff 100755 --- a/scripts/3-report/gcs_report.py +++ b/scripts/3-report/gcs_report.py @@ -59,6 +59,11 @@ def parse_arguments(): help="Enable git actions such as fetch, merge, add, commit, and push" " (default: False)", ) + parser.add_argument( + "--force", + action="store_true", + help="Regenerate data even if report files exist", + ) args = parser.parse_args() if not args.enable_save and args.enable_git: parser.error("--enable-git requires --enable-save") @@ -71,10 +76,20 @@ def parse_arguments(): def check_report_completion(args): - last_entry = shared.path_join(PATHS["data_phase"], "gcs_free_culture.png") - if os.path.exists(last_entry) and not args.force: - LOGGER.info(f"{last_entry} already exists. Script completed") + """ " + The function checks for the last plot and image + caption created in this script. This helps to + immediately know if all plots in the script have + been created and should not be regenerated. + + """ + if args.force: return + last_entry = shared.path_join(PATHS["data_phase"], "gcs_free_culture.png") + if os.path.exists(last_entry): + raise shared.QuantifyingException( + f"{last_entry} already exists. Report script completed", 0 + ) def gcs_intro(args): diff --git a/scripts/3-report/github_report.py b/scripts/3-report/github_report.py index 5f220555..f918842b 100755 --- a/scripts/3-report/github_report.py +++ b/scripts/3-report/github_report.py @@ -62,6 +62,11 @@ def parse_arguments(): action="store_true", help="Regenerate data even if images files already exist", ) + parser.add_argument( + "--force", + action="store_true", + help="Regenerate data even if report files exist", + ) args = parser.parse_args() if not args.enable_save and args.enable_git: parser.error("--enable-git requires --enable-save") @@ -74,12 +79,22 @@ def parse_arguments(): def check_report_completion(args): + """ " + The function checks for the last plot and image + caption created in this script. This helps to + immediately know if all plots in the script have + been created and should not be regenerated. + + """ + if args.force: + return last_entry = shared.path_join( PATHS["data_phase"], "github_restriction.png" ) - if os.path.exists(last_entry) and not args.force: - LOGGER.info(f"{last_entry} already exists. Script completed") - return + if os.path.exists(last_entry): + raise shared.QuantifyingException( + f"{last_entry} already exists. Report script completed", 0 + ) def load_data(args): diff --git a/scripts/3-report/wikipedia_report.py b/scripts/3-report/wikipedia_report.py index 44ca1e91..51c7d121 100755 --- a/scripts/3-report/wikipedia_report.py +++ b/scripts/3-report/wikipedia_report.py @@ -57,6 +57,11 @@ def parse_arguments(): help="Enable git actions such as fetch, merge, add, commit, and push" " (default: False)", ) + parser.add_argument( + "--force", + action="store_true", + help="Regenerate data even if report files exist", + ) args = parser.parse_args() if not args.enable_save and args.enable_git: parser.error("--enable-git requires --enable-save") @@ -69,12 +74,22 @@ def parse_arguments(): def check_report_completion(args): + """ " + The function checks for the last plot and image + caption created in this script. This helps to + immediately know if all plots in the script have + been created and should not be regenerated. + + """ + if args.force: + return last_entry = shared.path_join( PATHS["data_phase"], "wikipedia_least_language_usage.png" ) - if os.path.exists(last_entry) and not args.force: - LOGGER.info(f"{last_entry} already exists. Script completed") - return + if os.path.exists(last_entry): + raise shared.QuantifyingException( + f"{last_entry} already exists. Report script completed", 0 + ) def wikipedia_intro(args):