File size: 969 Bytes
4b7c478 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | import datetime
import glob
import subprocess
import tarfile
def create_submit_pkg():
# Source files
src_files = glob.glob("src/*.py")
# Notebooks
notebooks = glob.glob("*.ipynb")
# Genereate HTML files from the notebooks
for nb in notebooks:
cmd_line = f"jupyter nbconvert --to html {nb}"
print(f"executing: {cmd_line}")
subprocess.check_call(cmd_line, shell=True)
html_files = glob.glob("*.htm*")
now = datetime.datetime.today().isoformat(timespec="minutes").replace(":", "h")+"m"
outfile = f"submission_{now}.tar.gz"
print(f"Adding files to {outfile}")
with tarfile.open(outfile, "w:gz") as tar:
for name in (src_files + notebooks + html_files):
print(name)
tar.add(name)
print("")
msg = f"Done. Please submit the file {outfile}"
print("-" * len(msg))
print(msg)
print("-" * len(msg))
if __name__ == "__main__":
create_submit_pkg() |