This repository has been archived on 2023-07-17. You can view files and clone it, but cannot push or open issues or pull requests.
pushee/commands/base.py

38 lines
882 B
Python
Raw Normal View History

#!/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")