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

37 lines
942 B
Python
Raw Normal View History

2024-07-07 10:06:07 +00:00
#!/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
2024-07-07 10:06:07 +00:00
import os
import shutil
2024-07-07 10:06:07 +00:00
import sys
from pathlib import Path
2024-07-07 10:06:07 +00:00
if not os.getenv("QUARTO_PROJECT_RENDER_ALL"):
sys.exit(0)
relative_pub_dir = Path(
"../../../../public/blog/2024-07-02-nuclear-explosions-analysis/"
)
2024-07-07 10:06:07 +00:00
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.")
2024-07-07 10:06:07 +00:00
sys.exit(1)
src = "map.html"
shutil.copy(src, dest)
print("sucessfully moved map.html to ")