-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collecting the scripts into a single commandline program. (#64)
* Added argparse with some documentation and subcommands. It should work as before. * I think this works as intended.
- Loading branch information
1 parent
6b088f6
commit bf86d0a
Showing
9 changed files
with
190 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
name: Sanity check | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
python-check: | ||
runs-on: ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ pkgs ? import <nixpkgs> {} }: | ||
pkgs.mkShell { | ||
nativeBuildInputs = [ | ||
(pkgs.python39.withPackages(ps: with ps; [ | ||
ruamel-yaml | ||
( | ||
buildPythonPackage rec { | ||
pname = "canvasapi"; | ||
version = "2.2.0"; | ||
src = fetchPypi { | ||
inherit pname version; | ||
sha256 = "5087db773cac9d92f4f4609b3c160dbeeceb636801421808afee2d438bc43f62"; | ||
}; | ||
doCheck = false; | ||
propagatedBuildInputs = [ | ||
pkgs.python39Packages.pytz | ||
pkgs.python39Packages.requests | ||
]; | ||
} | ||
) | ||
])) | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env python3 | ||
|
||
|
||
import argparse | ||
import scan | ||
import download | ||
import info | ||
import upload | ||
import upload_single | ||
import os | ||
import sys | ||
from pathlib import Path | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
subparsers = parser.add_subparsers(title="subcommands", dest="subcommand") | ||
scan.add_subparser(subparsers) | ||
download.add_subparser(subparsers) | ||
info.add_subparser(subparsers) | ||
upload.add_subparser(subparsers) | ||
upload_single.add_subparser(subparsers) | ||
|
||
path_token = os.path.join( | ||
str(Path.home()), | ||
'.canvas.token' | ||
) | ||
|
||
if not os.path.exists(path_token): | ||
print(f'Error: Missing Canvas token at {path_token}.') | ||
sys.exit(0) | ||
|
||
api_url = 'https://absalon.ku.dk/' | ||
|
||
with open(path_token, 'r') as f: | ||
api_key = f.read().strip() | ||
|
||
args = parser.parse_args() | ||
if not hasattr(args, 'main'): | ||
parser.print_help() | ||
return | ||
|
||
args.main(api_url, api_key, args) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.