From 02dce5b7823f632fce7ec07cb35d3d872ed9e6e2 Mon Sep 17 00:00:00 2001 From: Due Date: Thu, 21 Sep 2023 01:13:29 +0200 Subject: [PATCH] I think this works as intended. --- shell.nix | 11 +++++------ staffeli_nt/__main__.py | 4 ++-- staffeli_nt/download.py | 7 +++---- staffeli_nt/info.py | 6 +++--- staffeli_nt/upload.py | 8 ++++---- staffeli_nt/upload_single.py | 2 +- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/shell.nix b/shell.nix index 1fad529..3967946 100644 --- a/shell.nix +++ b/shell.nix @@ -1,21 +1,20 @@ { pkgs ? import {} }: pkgs.mkShell { nativeBuildInputs = [ - (pkgs.python310.withPackages(ps: with ps; [ + (pkgs.python39.withPackages(ps: with ps; [ ruamel-yaml ( buildPythonPackage rec { pname = "canvasapi"; - version = "3.2.0"; + version = "2.2.0"; src = fetchPypi { inherit pname version; - sha256 = "7cf97ad1ddc860e250c3453e229897ed1273095ad061c34baf651bf1b0e5a9c7"; + sha256 = "5087db773cac9d92f4f4609b3c160dbeeceb636801421808afee2d438bc43f62"; }; doCheck = false; propagatedBuildInputs = [ - pkgs.python3Packages.arrow - pkgs.python3Packages.pytz - pkgs.python3Packages.requests + pkgs.python39Packages.pytz + pkgs.python39Packages.requests ]; } ) diff --git a/staffeli_nt/__main__.py b/staffeli_nt/__main__.py index 5037d91..4f3992f 100755 --- a/staffeli_nt/__main__.py +++ b/staffeli_nt/__main__.py @@ -29,10 +29,10 @@ def main(): print(f'Error: Missing Canvas token at {path_token}.') sys.exit(0) - api_key = 'https://absalon.ku.dk/' + api_url = 'https://absalon.ku.dk/' with open(path_token, 'r') as f: - api_url = f.read().strip() + api_key = f.read().strip() args = parser.parse_args() if not hasattr(args, 'main'): diff --git a/staffeli_nt/download.py b/staffeli_nt/download.py index e45b5bb..c1d997b 100755 --- a/staffeli_nt/download.py +++ b/staffeli_nt/download.py @@ -49,9 +49,9 @@ def add_subparser(subparsers: argparse._SubParsersAction): parser.add_argument('course_id', type=str, metavar='INT', help='the course id') parser.add_argument('path_template', type=str, metavar='TEMPLATE_PATH', help='path to the YAML template') parser.add_argument('path_destination', type=str, metavar='SUBMISSIONS_PATH', help='destination to submissions folder') - parser.add_argument('--select-section', action='store_false', help='whether section selection is used') + parser.add_argument('--select-section', action='store_true', help='whether section selection is used') parser.add_argument('--select-ta', type=str, metavar='PATH', help='path to a YAML file with TA distributions') - parser.add_argument('--resub', action='store_false', help='whether only resubmissions should be fetched') + parser.add_argument('--resub', action='store_true', help='whether only resubmissions should be fetched') parser.set_defaults(main=main) @@ -61,7 +61,6 @@ def main(api_url, api_key, args: argparse.Namespace): path_destination = args.path_destination select_section = args.select_section select_ta = args.select_ta # use --select-ta file.yaml - resubmissions_only = args.resub # sanity check @@ -148,7 +147,7 @@ def main(api_url, api_key, args: argparse.Namespace): # NOTE: This is a terribly hacky solution and should really be rewritten # collect which attachments to download # if only fetching resubmissions - if resubmissions_only: + if resubmissions_only: if hasattr(submission, 'score'): print(f'Score: {submission.score}') # If a submission has not yet been graded, submission.score will be None diff --git a/staffeli_nt/info.py b/staffeli_nt/info.py index 4e38700..82d4f4a 100755 --- a/staffeli_nt/info.py +++ b/staffeli_nt/info.py @@ -250,10 +250,10 @@ def get_course(api_url, api_key, course_id): def add_subparser(subparsers: argparse._SubParsersAction): parser : argparse.ArgumentParser = subparsers.add_parser(name='info', help='fetch infomation related to a course') parser.add_argument('course_id', type=str, metavar='INT', help='the course id') - parser.add_argument('--quiet', action='store_false', help='disable verbose output') - parser.add_argument('--debug', action='store_false', help='enable debug printing') + parser.add_argument('--quiet', action='store_true', help='disable verbose output') + parser.add_argument('--debug', action='store_true', help='enable debug printing') parser.add_argument('--get-ass-dist', metavar='PATH', help=("select an assignment and construct a distribution between available TA's, resulting in a YAML-file suitable for using with the --select-ta flag in download subcommand where the result will be written to PATH")) - parser.add_argument('--ids', action='store_false', help='print kuids and names for a sections') + parser.add_argument('--ids', action='store_true', help='print kuids and names for a sections') parser.set_defaults(main=main) diff --git a/staffeli_nt/upload.py b/staffeli_nt/upload.py index 9341a3e..f96ba83 100755 --- a/staffeli_nt/upload.py +++ b/staffeli_nt/upload.py @@ -60,10 +60,10 @@ def add_subparser(subparsers: argparse._SubParsersAction): parser : argparse.ArgumentParser = subparsers.add_parser(name='upload', help='upload feedback for submissions') parser.add_argument('path_template', type=str, metavar='TEMPLATE_PATH', help='path to the YAML template') parser.add_argument('path_submissions', type=str, metavar='SUBMISSIONS_PATH', help='destination to submissions folder') - parser.add_argument('--live', action='store_false', help='upload all feedback for submissions in the directory') - parser.add_argument('--step', action='store_false', help='to review all feedback for submissions in the directory') - parser.add_argument('--warn-missing', action='store_false', help='warn if grades are missing') - parser.add_argument('--write-local', action='store_false', help='writes the feedback locally unless --live is given') + parser.add_argument('--live', action='store_true', help='upload all feedback for submissions in the directory') + parser.add_argument('--step', action='store_true', help='to review all feedback for submissions in the directory') + parser.add_argument('--warn-missing', action='store_true', help='warn if grades are missing') + parser.add_argument('--write-local', action='store_true', help='writes the feedback locally unless --live is given') parser.set_defaults(main=main) def main(api_url, api_key, args: argparse.Namespace): diff --git a/staffeli_nt/upload_single.py b/staffeli_nt/upload_single.py index 21ef14d..0743083 100755 --- a/staffeli_nt/upload_single.py +++ b/staffeli_nt/upload_single.py @@ -33,7 +33,7 @@ def add_subparser(subparsers: argparse._SubParsersAction): parser.add_argument('path_meta_yml', type=str, metavar='META_PATH', help='YAML file containg meta data related to the submission') parser.add_argument('path_grade_yml', type=str, metavar='GRADE_PATH', help='YAML file containing the grade') parser.add_argument('path_feedback', type=str, metavar='FEEDBACK_PATH', help='the path to the text file containing feedback') - parser.add_argument('--live', action='store_false', help='upload feedback for submission') + parser.add_argument('--live', action='store_true', help='upload feedback for submission') parser.set_defaults(main=main)