#!/usr/bin/env python3
import os
import re
import requests
from subprocess import run
import sys
from commands import MergeRequests, UpdateAssignees, Comments, Merge, Test
from constants import SUBMISSIONS, HOMEWORK
from git import checkout_branch
from utils import get_branch, mkcd, make_pair
def iterate_logins(func):
for login, submission in map(make_pair, SUBMISSIONS):
branch = get_branch(login)
checkout_branch(branch)
mkcd(f"{HOMEWORK}/{login}")
func(login, submission)
os.chdir("../..")
checkout_branch("master")
COMMANDS = {
"mrs": MergeRequests(),
"update-assignees": UpdateAssignees(),
"comments": Comments(),
"merge": Merge(),
"test": Test(),
}
def main():
if sys.argv[1] not in COMMANDS:
print("Invalid command")
exit(2)
iterate_logins(COMMANDS[sys.argv[1]])
if __name__ == "__main__":
main()