|
11 | 11 | import traceback |
12 | 12 |
|
13 | 13 | # Third-party |
14 | | -# import pandas as pd |
15 | 14 | import pandas as pd |
16 | 15 |
|
17 | 16 | # Add parent directory so shared can be imported |
@@ -60,6 +59,13 @@ def parse_arguments(): |
60 | 59 | return args |
61 | 60 |
|
62 | 61 |
|
| 62 | +def check_for_data_file(file_path): |
| 63 | + if os.path.exists(file_path): |
| 64 | + raise shared.QuantifyingException( |
| 65 | + f"Processed data already exists for {QUARTER}", 0 |
| 66 | + ) |
| 67 | + |
| 68 | + |
63 | 69 | def data_to_csv(args, data, file_path): |
64 | 70 | if not args.enable_save: |
65 | 71 | return |
@@ -92,6 +98,7 @@ def process_totals_by_license(args, count_data): |
92 | 98 | file_path = shared.path_join( |
93 | 99 | PATHS["data_phase"], "github_totals_by_license.csv" |
94 | 100 | ) |
| 101 | + check_for_data_file(file_path) |
95 | 102 | data_to_csv(args, data, file_path) |
96 | 103 |
|
97 | 104 |
|
@@ -126,52 +133,10 @@ def process_totals_by_restriction(args, count_data): |
126 | 133 | file_path = shared.path_join( |
127 | 134 | PATHS["data_phase"], "github_totals_by_restriction.csv" |
128 | 135 | ) |
| 136 | + check_for_data_file(file_path) |
129 | 137 | data_to_csv(args, data, file_path) |
130 | 138 |
|
131 | 139 |
|
132 | | -# def load_quarter_data(quarter): |
133 | | -# """ |
134 | | -# Load data for a specific quarter. |
135 | | -# """ |
136 | | -# file_path = os.path.join(PATHS["data"], f"{quarter}", |
137 | | -# "1-fetch", "github_fetched") |
138 | | -# if not os.path.exists(file_path): |
139 | | -# LOGGER.error(f"Data file for quarter {quarter} not found.") |
140 | | -# return None |
141 | | -# return pd.read_csv(file_path) |
142 | | - |
143 | | - |
144 | | -# def compare_data(current_quarter, previous_quarter): |
145 | | -# """ |
146 | | -# Compare data between two quarters. |
147 | | -# """ |
148 | | -# current_data = load_quarter_data(current_quarter) |
149 | | -# previous_data = load_quarter_data(previous_quarter) |
150 | | - |
151 | | -# if current_data is None or previous_data is None: |
152 | | -# return |
153 | | - |
154 | | -# Process data to compare totals |
155 | | - |
156 | | - |
157 | | -# def parse_arguments(): |
158 | | -# """ |
159 | | -# Parses command-line arguments, returns parsed arguments. |
160 | | -# """ |
161 | | -# LOGGER.info("Parsing command-line arguments") |
162 | | -# parser = argparse.ArgumentParser( |
163 | | -# description="Google Custom Search Comparison Report") |
164 | | -# parser.add_argument( |
165 | | -# "--current_quarter", type=str, required=True, |
166 | | -# help="Current quarter for comparison (e.g., 2024Q3)" |
167 | | -# ) |
168 | | -# parser.add_argument( |
169 | | -# "--previous_quarter", type=str, required=True, |
170 | | -# help="Previous quarter for comparison (e.g., 2024Q2)" |
171 | | -# ) |
172 | | -# return parser.parse_args() |
173 | | - |
174 | | - |
175 | 140 | def main(): |
176 | 141 | args = parse_arguments() |
177 | 142 | shared.paths_log(LOGGER, PATHS) |
|
0 commit comments