Skip to content

Commit afdbbea

Browse files
committed
added function for automation
1 parent 0266293 commit afdbbea

File tree

3 files changed

+13
-45
lines changed

3 files changed

+13
-45
lines changed

scripts/1-fetch/wikipedia_fetch.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ def parse_arguments():
6363
return args
6464

6565

66+
def check_for_completion():
67+
try:
68+
with open(FILE_LANGUAGES, "r", newline="") as file_obj:
69+
reader = csv.DictReader(file_obj, dialect="unix")
70+
if len(list(reader)) > 0:
71+
raise shared.QuantifyingException(
72+
f"Data fetch completed for {QUARTER}", 0
73+
)
74+
except FileNotFoundError:
75+
pass # File may not be found without --enable-save, etc.
76+
77+
6678
def write_data(args, tool_data):
6779
if not args.enable_save:
6880
return args
@@ -157,6 +169,7 @@ def query_wikipedia_languages(session):
157169
def main():
158170
args = parse_arguments()
159171
shared.paths_log(LOGGER, PATHS)
172+
check_for_completion()
160173
shared.git_fetch_and_merge(args, PATHS["repo"])
161174
session = shared.get_session()
162175
tool_data = query_wikipedia_languages(session)

scripts/2-process/github_process.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import traceback
1212

1313
# Third-party
14-
# import pandas as pd
1514
import pandas as pd
1615

1716
# Add parent directory so shared can be imported
@@ -129,49 +128,6 @@ def process_totals_by_restriction(args, count_data):
129128
data_to_csv(args, data, file_path)
130129

131130

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-
175131
def main():
176132
args = parse_arguments()
177133
shared.paths_log(LOGGER, PATHS)

scripts/2-process/wikipedia_process.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ def main():
147147
args = parse_arguments()
148148
shared.paths_log(LOGGER, PATHS)
149149
shared.git_fetch_and_merge(args, PATHS["repo"])
150-
151150
file_count = shared.path_join(
152151
PATHS["data_1-fetch"], "wikipedia_count_by_languages.csv"
153152
)

0 commit comments

Comments
 (0)