nuclear_explosions/tools/move-map-to-blog.py

37 lines
942 B
Python

#!/usr/bin/env python3
# Simply move the map.png file to the blog output dir
# since it won't do so automatically for pillow creations.
# A HACK TO PUT THE LEAFLET JS INTO THE CORRECT PUBLIC BLOG DIR
# will have to be changed when the hardcoded public dir path changes
import os
import shutil
import sys
from pathlib import Path
if not os.getenv("QUARTO_PROJECT_RENDER_ALL"):
sys.exit(0)
relative_pub_dir = Path(
"../../../../public/blog/2024-07-02-nuclear-explosions-analysis/"
)
q_output_dir = os.getenv("QUARTO_PROJECT_OUTPUT_DIR")
if not q_output_dir:
print(f"ERROR: output dir: {q_output_dir} DOES NOT EXIST.")
sys.exit(1)
dest = Path(q_output_dir).joinpath(relative_pub_dir)
# Correct relative WORKING DIR DOES NOT EXIST
if not dest.is_dir():
print(f"ERROR: map.html destination path: {dest} DOES NOT EXIST.")
sys.exit(1)
src = "map.html"
shutil.copy(src, dest)
print("sucessfully moved map.html to ")