import os
import re
# Change the following two paths to run the script (please provide full paths)
DP_TEXT_ROOT_DIR_PATH = '/Users/thebigbool/repos/dp_text_1'
BOOK_DP_ROOT_DIR_PATH = '/Users/thebigbool/repos/book-dp1'
chapter_files = []
for filename in os.listdir(DP_TEXT_ROOT_DIR_PATH):
if filename.startswith("ch_") and filename.endswith(".tex"):
chapter_files.append(filename)
# print("Chapter files in DP-Text")
# print(chapter_files)
file_match_regex = re.compile(r'source_code/([a-zA-Z_][a-zA-Z_0-9]*).jl')
source_code_julia_files = [] # contains file names that were used in source code
for file in chapter_files:
full_path = os.path.join(DP_TEXT_ROOT_DIR_PATH, file)
with open(full_path, 'r') as f:
for line in f.readlines():
match_ = file_match_regex.search(line)
if match_:
source_code_julia_files.append(
match_.group(0).replace("source_code/", ""))
# print("Source code of julia used in the dp-text")
# print(source_code_julia_files)
source_code_py_files = [] # contains python code file names
py_files_path = os.path.join(BOOK_DP_ROOT_DIR_PATH, 'source_code_py')
source_code_py_files = os.listdir(py_files_path)
missing_files = []
for file in source_code_julia_files:
file_name = file.replace(".jl", "") + ".py"
if file_name not in source_code_py_files:
missing_files.append(file_name)
if not missing_files:
print("No missing files")
else:
for file_name in missing_files:
print("Missing python file:", file_name)
Presently this prints:
cc @jstac