diff --git a/auto-update-dataset/python/prStatusCheck.py b/auto-update-dataset/python/prStatusCheck.py index efca2773..e48608f7 100644 --- a/auto-update-dataset/python/prStatusCheck.py +++ b/auto-update-dataset/python/prStatusCheck.py @@ -51,19 +51,20 @@ REPORT_PATH = os.path.join(script_dir, "accepted.log") MANUAL_CHECK_PATH = os.path.join(script_dir, "manual-check.log") -def fetch_status(url, original_status): + +def fetch_status(url, original_status): """ Fetch PR status from GitHub API with caching. """ - + def cache_and_return(url, result): """Cache the result and return it.""" pr_status_cache[url] = result return result - + if url in pr_status_cache: logger.debug(f"Cache hit for {url}") - return pr_status_cache[url] + return pr_status_cache[url] match = GITHUB_URL_PATTERN.search(url) if not match: return cache_and_return(url, "Invalid URL") @@ -90,6 +91,7 @@ def cache_and_return(url, result): logger.warning(f"Exception fetching PR {url}: {e}.") return "Fetch Error" + def process_row(filename, index, row): """ Only check for updates when the PR is in 'Opened' status. @@ -121,6 +123,7 @@ def process_row(filename, index, row): logger.info(msg) return index, new_status, changed, url, msg + def parse_range(range_str): if not range_str: return None, None @@ -140,6 +143,7 @@ def parse_range(range_str): logger.error(f"Invalid range values: {range_str}") sys.exit(1) + def main(): parser = argparse.ArgumentParser(description="Update PR statuses in CSV files.") parser.add_argument("--prrange", type=str, @@ -275,5 +279,6 @@ def main(): f.write(line + "\n") logger.info(f"Manual check log updated for {filename}") + if __name__ == "__main__": - main() \ No newline at end of file + main()