mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-07-16 06:07:17 -05:00
- Migrated all legacy constants from constants.py to hardware and model registries - Updated dozens of LEGO blocks in Volume 1 and Volume 2 to use Engine.solve and formulas - Resolved all resulting NameError, TypeError, and AttributeError exceptions in the inline Python blocks - Master Quarto HTML build now passes with zero execution failures
34 lines
832 B
Python
34 lines
832 B
Python
import glob
|
|
import traceback
|
|
import sys
|
|
|
|
qmd_files = sorted(glob.glob('book/quarto/contents/**/*.qmd', recursive=True))
|
|
|
|
failed = False
|
|
for qmd in qmd_files:
|
|
with open(qmd, 'r') as f:
|
|
content = f.read()
|
|
|
|
import re
|
|
blocks = re.findall(r'```\{python\}(.*?)```', content, re.DOTALL)
|
|
if not blocks:
|
|
continue
|
|
|
|
combined_code = "\n".join(blocks)
|
|
|
|
# We execute it in a clean dictionary to act as the global namespace
|
|
namespace = {}
|
|
try:
|
|
exec(combined_code, namespace)
|
|
except Exception as e:
|
|
failed = True
|
|
print(f"❌ Error in {qmd}:")
|
|
traceback.print_exc(limit=0, file=sys.stdout)
|
|
print("-" * 40)
|
|
|
|
if not failed:
|
|
print("✅ All Python blocks executed successfully across the entire book!")
|
|
sys.exit(0)
|
|
else:
|
|
sys.exit(1)
|