@@ -57,6 +57,11 @@ def parse_arguments():
5757 help = "Enable git actions such as fetch, merge, add, commit, and push"
5858 " (default: False)" ,
5959 )
60+ parser .add_argument (
61+ "--force" ,
62+ action = "store_true" ,
63+ help = "Regenerate data even if report files exist" ,
64+ )
6065 args = parser .parse_args ()
6166 if not args .enable_save and args .enable_git :
6267 parser .error ("--enable-git requires --enable-save" )
@@ -68,6 +73,25 @@ def parse_arguments():
6873 return args
6974
7075
76+ def check_report_completion (args ):
77+ """ "
78+ The function checks for the last plot and image
79+ caption created in this script. This helps to
80+ immediately know if all plots in the script have
81+ been created and should not be regenerated.
82+
83+ """
84+ if args .force :
85+ return
86+ last_entry = shared .path_join (
87+ PATHS ["data_phase" ], "wikipedia_least_language_usage.png"
88+ )
89+ if os .path .exists (last_entry ):
90+ raise shared .QuantifyingException (
91+ f"{ last_entry } already exists. Report script completed" , 0
92+ )
93+
94+
7195def wikipedia_intro (args ):
7296 """
7397 Write Wikipedia introduction.
@@ -261,6 +285,7 @@ def main():
261285 args = parse_arguments ()
262286 shared .paths_log (LOGGER , PATHS )
263287 shared .git_fetch_and_merge (args , PATHS ["repo" ])
288+ check_report_completion (args )
264289 wikipedia_intro (args )
265290 plot_language_representation (args )
266291 plot_highest_language_usage (args )
0 commit comments