learn_jax/check_time.py

27 lines
880 B
Python

from pathlib import Path
# Define the folder to check
folder = Path(".")
# Get all .py and .ipynb files in the folder
py_files = {file.stem: file for file in folder.glob("*.py")}
ipynb_files = {file.stem: file for file in folder.glob("*.ipynb")}
# Check for linked .py and .ipynb files
all_newer = True
for stem, py_file in py_files.items():
if stem in ipynb_files:
ipynb_file = ipynb_files[stem]
# Compare the modification times
if py_file.stat().st_mtime > ipynb_file.stat().st_mtime:
print(f"{py_file} is newer than {ipynb_file}.")
else:
print(f"{py_file} is not newer than {ipynb_file}.")
all_newer = False
if all_newer:
print("All linked .py files are newer than their corresponding .ipynb files.")
else:
print("Some .py files are not newer than their corresponding .ipynb files.")