#!/bin/bash
#NOTE: DO NOT EDIT THIS FILE-- MAY RESULT IN INCOMPLETE SUBMISSIONS
set -euo pipefail

CODE=(
    "Man/cfg.mat"
    "Man/groundtruth_rect.txt"
    "Man/img/0001.jpg"
    "Man/img/0002.jpg"
    "Man/img/0003.jpg"
    "Man/img/0004.jpg"
    "Man/img/0005.jpg"
    "Man/img/0006.jpg"
    "Man/img/0007.jpg"
    "Man/img/0008.jpg"
    "Man/img/0009.jpg"
    "Man/img/0010.jpg"
    "Man/img/0011.jpg"
    "Man/img/0012.jpg"
    "Man/img/0013.jpg"
    "Man/img/0014.jpg"
    "Man/img/0015.jpg"
    "Man/img/0016.jpg"
    "Man/img/0017.jpg"
    "Man/img/0018.jpg"
    "Man/img/0019.jpg"
    "Man/img/0020.jpg"
    "Man/img/0021.jpg"
    "Man/img/0022.jpg"
    "Man/img/0023.jpg"
    "Man/img/0024.jpg"
    "Man/img/0025.jpg"
    "Man/img/0026.jpg"
    "Man/img/0027.jpg"
    "Man/img/0028.jpg"
    "Man/img/0029.jpg"
    "Man/img/0030.jpg"
    "Man/img/0031.jpg"
    "Man/img/0032.jpg"
    "Man/img/0033.jpg"
    "Man/img/0034.jpg"
    "Man/img/0035.jpg"
    "Man/img/0036.jpg"
    "Man/img/0037.jpg"
    "Man/img/0038.jpg"
    "Man/img/0039.jpg"
    "Man/img/0040.jpg"
    "Man/img/0041.jpg"
    "Man/img/0042.jpg"
    "Man/img/0043.jpg"
    "Man/img/0044.jpg"
    "Man/img/0045.jpg"
    "Man/img/0046.jpg"
    "Man/img/0047.jpg"
    "Man/img/0048.jpg"
    "Man/img/0049.jpg"
    "Man/img/0050.jpg"
    "Man/img/0051.jpg"
    "Man/img/0052.jpg"
    "Man/img/0053.jpg"
    "Man/img/0054.jpg"
    "Man/img/0055.jpg"
    "Man/img/0056.jpg"
    "Man/img/0057.jpg"
    "Man/img/0058.jpg"
    "Man/img/0059.jpg"
    "Man/img/0060.jpg"
    "Man/img/0061.jpg"
    "Man/img/0062.jpg"
    "Man/img/0063.jpg"
    "Man/img/0064.jpg"
    "Man/img/0065.jpg"
    "Man/img/0066.jpg"
    "Man/img/0067.jpg"
    "Man/img/0068.jpg"
    "Man/img/0069.jpg"
    "Man/img/0070.jpg"
    "Man/img/0071.jpg"
    "Man/img/0072.jpg"
    "Man/img/0073.jpg"
    "Man/img/0074.jpg"
    "Man/img/0075.jpg"
    "Man/img/0076.jpg"
    "Man/img/0077.jpg"
    "Man/img/0078.jpg"
    "Man/img/0079.jpg"
    "Man/img/0080.jpg"
    "Man/img/0081.jpg"
    "Man/img/0082.jpg"
    "Man/img/0083.jpg"
    "Man/img/0084.jpg"
    "Man/img/0085.jpg"
    "Man/img/0086.jpg"
    "Man/img/0087.jpg"
    "Man/img/0088.jpg"
    "Man/img/0089.jpg"
    "Man/img/0090.jpg"
    "Man/img/0091.jpg"
    "Man/img/0092.jpg"
    "Man/img/0093.jpg"
    "Man/img/0094.jpg"
    "Man/img/0095.jpg"
    "Man/img/0096.jpg"
    "Man/img/0097.jpg"
    "Man/img/0098.jpg"
    "Man/img/0099.jpg"
    "Man/img/0100.jpg"
    "Man/img/0101.jpg"
    "Man/img/0102.jpg"
    "Man/img/0103.jpg"
    "Man/img/0104.jpg"
    "Man/img/0105.jpg"
    "Man/img/0106.jpg"
    "Man/img/0107.jpg"
    "Man/img/0108.jpg"
    "Man/img/0109.jpg"
    "Man/img/0110.jpg"
    "Man/img/0111.jpg"
    "Man/img/0112.jpg"
    "Man/img/0113.jpg"
    "Man/img/0114.jpg"
    "Man/img/0115.jpg"
    "Man/img/0116.jpg"
    "Man/img/0117.jpg"
    "Man/img/0118.jpg"
    "Man/img/0119.jpg"
    "Man/img/0120.jpg"
    "Man/img/0121.jpg"
    "Man/img/0122.jpg"
    "Man/img/0123.jpg"
    "Man/img/0124.jpg"
    "Man/img/0125.jpg"
    "Man/img/0126.jpg"
    "Man/img/0127.jpg"
    "Man/img/0128.jpg"
    "Man/img/0129.jpg"
    "Man/img/0130.jpg"
    "Man/img/0131.jpg"
    "Man/img/0132.jpg"
    "Man/img/0133.jpg"
    "Man/img/0134.jpg"   
    "images/frame01.jpg"
    "images/frame02.jpg"
    "images/frame03.jpg"
    "images/frame04.jpg"
    "images/frame05.jpg"
    "images/frame06.jpg"
    "images/frame07.jpg"
    "images/frame08.jpg"
    "images/frame09.jpg"
    "images/frame10.jpg"
    "images/frame11.jpg"
    "images/frame12.jpg"
    "images/frame13.jpg"
    "motion.py"
    "ref_imgs/compute_error_final_frame.png"
    "ref_imgs/first_frame_keypoints.png"
    "ref_imgs/iterative_compute_error_final_frame.png"
    "ref_imgs/iterative_optical_flow_vectors.png"
    "ref_imgs/iterative_second_frame_tracked_keypoints.png"
    "ref_imgs/optical_flow_vectors.png"
    "ref_imgs/pyramid_compute_error_final_frame.png"
    "ref_imgs/pyramid_optical_flow_vectors.png"
    "ref_imgs/pyramid_second_frame_tracked_keypoints.png"
    "ref_imgs/second_frame_tracked_keypoints.png"
    "utils.py"
)

# these notebooks should ideally
# be in order of questions so
# that the generated pdf is
# in order of questions
NOTEBOOKS=(
	"Motion.ipynb"
)

FILES=( "${CODE[@]}" "${NOTEBOOKS[@]}" )

LOCAL_DIR=`pwd`
ASSIGNMENT_NO=5
ZIP_FILENAME="a5_code_submission.zip"
PDF_FILENAME="a5_inline_submission.pdf"

C_R="\e[31m"
C_G="\e[32m"
C_BLD="\e[1m"
C_E="\e[0m"

for FILE in "${FILES[@]}"
do
	if [ ! -f ${FILE} ]; then
		echo -e "${C_R}Required file ${FILE} not found, Exiting.${C_E}"
		exit 0
	fi
done

echo -e "### Zipping file ###"
rm -f ${ZIP_FILENAME}
zip -q "${ZIP_FILENAME}" -r ${NOTEBOOKS[@]} $(find . -name "*.py") -x "makepdf.py"

echo -e "### Creating PDFs ###"
python makepdf.py --notebooks "${NOTEBOOKS[@]}" --pdf_filename "${PDF_FILENAME}"

echo -e "### Done! Please submit ${ZIP_FILENAME} and ${PDF_FILENAME} to Gradescope. ###"
