From d8d9a0abc2678de51cab23d19a760469e09320f5 Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Sun, 10 Oct 2021 18:37:26 +0800 Subject: Take in CLI arguments Four arguments. The required one is -n / --homework-number Plus three flags to bypass respective checks -I / --no-individual -G / --no-group -J / --no-joj --- leningrade.py | 52 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/leningrade.py b/leningrade.py index 167b3cf..aec0383 100644 --- a/leningrade.py +++ b/leningrade.py @@ -1,16 +1,35 @@ +import argparse from worker import GitWorker, GiteaWorker, JOJWorker from config import * +parser = argparse.ArgumentParser("leningrade") +parser.add_argument( + "-n", + "--homework-number", + type=int, + required=True, + help="An integer. For h1, the value should be 1.", +) +parser.add_argument("-I", "--no-individual", action="store_true", default=False) +parser.add_argument("-G", "--no-group", action="store_true", default=False) +parser.add_argument( + "-J", + "--no-joj", + action="store_true", + default=False, + help="JOJ may consume a lot of time. Set this flag if your group work has proven to pass JOJ.", +) + +cli_args = parser.parse_args() + + class Arguments: - indv = True + hw = HOMEWORK_NO + rejudge = HGROUP_NO # I do not understand the naming dir = True - group = True - joj = True tidy = True score = True - hw = HOMEWORK_NO - rejudge = HGROUP_NO args = Arguments() @@ -32,14 +51,17 @@ JOJ_INFO = { } # individual -indvScores = gitWorker.checkIndv() -print(indvScores) +if not cli_args.no_individual: + indvScores = gitWorker.checkIndv() + print(indvScores) # group -groupScores = gitWorker.checkGroup() -tmpScores = giteaWorker.checkReview() -for key in groupScores.keys(): - groupScores[key] = {**groupScores.get(key, {}), **tmpScores.get(key, {})} -print(groupScores) -# JOJ -jojScores = jojWorker.checkGroupJOJ(JOJ_INFO) -print(jojScores) +if not cli_args.no_group: + groupScores = gitWorker.checkGroup() + tmpScores = giteaWorker.checkReview() + for key in groupScores.keys(): + groupScores[key] = {**groupScores.get(key, {}), **tmpScores.get(key, {})} + print(groupScores) +# JOJ (This will consume a lot of time when the code is in MATLAB) +if not cli_args.no_joj: + jojScores = jojWorker.checkGroupJOJ(JOJ_INFO) + print(jojScores) -- cgit v1.2.3