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

39 lines
930 B
Python
Raw Normal View History

#!/usr/bin/env python3
import os
2020-04-03 14:10:37 +02:00
from typing import Dict, List
from git import checkout_branch
2019-12-12 12:15:52 +01:00
from gitlab import Gitlab
2019-11-30 17:47:52 +01:00
from utils import mkcd
from submission import Submission
class BaseCommand:
2020-06-08 17:39:36 +02:00
def __init__(
self, submissions: List[Submission], gitlab: Gitlab, details: Dict
) -> None:
2019-11-30 17:47:52 +01:00
self.submissions = submissions
2019-12-12 12:15:52 +01:00
self.gitlab = gitlab
2020-04-03 14:10:37 +02:00
self.hw = details
2019-11-30 17:47:52 +01:00
def __call__(self) -> None:
for submission in self.submissions:
self.exec(submission)
2019-11-30 17:47:52 +01:00
def exec(self, submission: Submission) -> None:
raise NotImplementedError()
class BaseGitCommand(BaseCommand):
2019-11-30 17:47:52 +01:00
def __call__(self) -> None:
for submission in self.submissions:
checkout_branch(submission.branch)
mkcd(f"{submission.homework}/{submission.login}")
2019-11-30 17:47:52 +01:00
self.exec(submission)
os.chdir("../..")
2019-11-30 17:47:52 +01:00
checkout_branch("master")