@@ -62,6 +62,13 @@ def parse_arguments():
6262 return args
6363
6464
65+ def check_for_data_file (file_path ):
66+ if os .path .exists (file_path ):
67+ raise shared .QuantifyingException (
68+ f"Processed data already exists for { QUARTER } " , 0
69+ )
70+
71+
6572def data_to_csv (args , data , file_path ):
6673 if not args .enable_save :
6774 return
@@ -111,6 +118,7 @@ def process_product_totals(args, count_data):
111118 data .items (), columns = ["CC legal tool product" , "Count" ]
112119 )
113120 file_path = shared .path_join (PATHS ["data_phase" ], "gcs_product_totals.csv" )
121+ check_for_data_file (file_path )
114122 data_to_csv (args , data , file_path )
115123
116124
@@ -192,7 +200,8 @@ def process_latest_prior_retired_totals(args, count_data):
192200 file_path = shared .path_join (
193201 PATHS ["data_phase" ], f"gcs_status_{ key } _totals.csv"
194202 )
195- data_to_csv (args , dataframe , file_path )
203+ check_for_data_file (file_path )
204+ data_to_csv (args , dataframe , file_path )
196205
197206
198207def process_totals_by_free_cultural (args , count_data ):
@@ -225,6 +234,7 @@ def process_totals_by_free_cultural(args, count_data):
225234 file_path = shared .path_join (
226235 PATHS ["data_phase" ], "gcs_totals_by_free_cultural.csv"
227236 )
237+ check_for_data_file (file_path )
228238 data_to_csv (args , data , file_path )
229239
230240
@@ -259,6 +269,7 @@ def process_totals_by_restrictions(args, count_data):
259269 file_path = shared .path_join (
260270 PATHS ["data_phase" ], "gcs_totals_by_restrictions.csv"
261271 )
272+ check_for_data_file (file_path )
262273 data_to_csv (args , data , file_path )
263274
264275
@@ -280,6 +291,7 @@ def process_totals_by_language(args, data):
280291 file_path = shared .path_join (
281292 PATHS ["data_phase" ], "gcs_totals_by_language.csv"
282293 )
294+ check_for_data_file (file_path )
283295 data_to_csv (args , data , file_path )
284296
285297
@@ -301,6 +313,7 @@ def process_totals_by_country(args, data):
301313 file_path = shared .path_join (
302314 PATHS ["data_phase" ], "gcs_totals_by_country.csv"
303315 )
316+ check_for_data_file (file_path )
304317 data_to_csv (args , data , file_path )
305318
306319
0 commit comments