competitive programming scripts on Linux
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB

#!/usr/bin/env python3
import argparse
import os
import subprocess
import shutil
# set up this in order to point to proper directory.
setup_dir = os.path.dirname(__file__)
os.environ["CP_SETUP_DIR"] = os.path.dirname(__file__)
parser = argparse.ArgumentParser()
templates = ["py", "std", "selfio", "java", "minjava", "rb", "rust"]
def file_option():
global parser
for s in templates:
parser.add_argument("-" + s, default=[], type=str, nargs="*")
def add_download(filename, prefix=""):
global setup_dir
template = os.path.join(setup_dir, prefix, "")
script = os.path.join(filename, prefix, "")
shutil.copyfile(template, script)
os.system(f"chmod +x {script}")
in order to make a new template, add it to file_option,
create a new script in prob_maker, and then call as below.
problems = parser.parse_args()
for t in templates:
for filename in problems.__dict__[t]:["bash", os.path.join(setup_dir, "prob_maker", t + ".sh"), filename])
prefix = "src" if t == "rust" else ""
add_download(filename, prefix=prefix)