<filename>set_up_day.py
#!/bin/python3
from pathlib import Path
import sys
import datetime
import shutil

LATEST_YEAR = datetime.date.today().year

def _validate_cli_args():
    if len(sys.argv) == 3:
        if sys.argv[1].isdigit() and int(sys.argv[1]) in range(2015,LATEST_YEAR+1) and \
            sys.argv[2].isdigit() and int(sys.argv[2]) in range(1,26):
            return True
        else:
            return False
    else:
        return False

def copy_template_file(src, dest):
    try:
        with open(dest) as file:
            pass
    except:
        shutil.copyfile(src, dest)

def create_file_with_content(dest, content):
    try:
        with open(dest) as file:
            pass
    except:
        with open(dest, "w") as file:
            file.write(content)

if __name__ == "__main__":
    # Check cli arguments are correct
    if not _validate_cli_args():
        print(f"Incorrect cli argument. Example:\n\tpython set_up_day.py YEAR(2015-{LATEST_YEAR}) DAY(1-25)")
        sys.exit()
    
    # Create directories if needed
    goPath = f"./{sys.argv[1]}/{sys.argv[2]}/go/"
    Path(goPath).mkdir(parents=True, exist_ok=True)
    goPath += "main.go"

    pyPath = f"./{sys.argv[1]}/{sys.argv[2]}/python/"
    Path(pyPath).mkdir(parents=True, exist_ok=True)
    pyPath += "main.py"

    # Copy template file into destination file if needed
    # Go file
    copy_template_file('./template/template_go.go', goPath)

    # Python file
    copy_template_file('./template/template_python.py', pyPath)

    # Directions file
    diPath = f"./{sys.argv[1]}/{sys.argv[2]}/directions.txt"
    create_file_with_content(diPath, "Enter directions here.")

    # Input file
    inPath = f"./{sys.argv[1]}/{sys.argv[2]}/input.txt"
    create_file_with_content(inPath, "Enter input here.")

    print(f"\t{sys.argv[1]}/{sys.argv[2]} Directories and files present and ready.")