38 lines
882 B
Python
38 lines
882 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
|
||
|
import os
|
||
|
|
||
|
|
||
|
from constants import HOMEWORK
|
||
|
from git import checkout_branch
|
||
|
from utils import make_pair, get_branch, mkcd
|
||
|
|
||
|
|
||
|
class BaseCommand:
|
||
|
def __init__(self, submissions):
|
||
|
self.submissions = map(make_pair, submissions)
|
||
|
self.branch = None
|
||
|
|
||
|
def __call__(self):
|
||
|
for login, submission in self.submissions:
|
||
|
self.branch = get_branch(login)
|
||
|
|
||
|
self.exec(login, submission)
|
||
|
|
||
|
def exec(self, login: str, submission: str):
|
||
|
raise NotImplementedError()
|
||
|
|
||
|
|
||
|
class BaseGitCommand(BaseCommand):
|
||
|
def __call__(self):
|
||
|
for login, submission in self.submissions:
|
||
|
self.branch = get_branch(login)
|
||
|
|
||
|
checkout_branch(self.branch)
|
||
|
mkcd(f"{HOMEWORK}/{login}")
|
||
|
|
||
|
self.exec(login, submission)
|
||
|
|
||
|
os.chdir("../..")
|
||
|
checkout_branch("master")
|