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
2020-06-08 17:39:36 +02:00

38 lines
930 B
Python

#!/usr/bin/env python3
import os
from typing import Dict, List
from git import checkout_branch
from gitlab import Gitlab
from utils import mkcd
from submission import Submission
class BaseCommand:
def __init__(
self, submissions: List[Submission], gitlab: Gitlab, details: Dict
) -> None:
self.submissions = submissions
self.gitlab = gitlab
self.hw = details
def __call__(self) -> None:
for submission in self.submissions:
self.exec(submission)
def exec(self, submission: Submission) -> None:
raise NotImplementedError()
class BaseGitCommand(BaseCommand):
def __call__(self) -> None:
for submission in self.submissions:
checkout_branch(submission.branch)
mkcd(f"{submission.homework}/{submission.login}")
self.exec(submission)
os.chdir("../..")
checkout_branch("master")