diff --git a/.gitignore b/.gitignore index 248848d2268781f50da56504d664dbf24c4fcd80..88315dae8ef33b41e3f2f2f1aff1c160ca99860f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,50 @@ -bbcli/__pycache__ -tests/__pycache__ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Rope +.ropeproject + +# Django stuff: +*.log +*.pot + +# Sphinx documentation +docs/_build/ \ No newline at end of file diff --git a/bbcli/__pycache__/__init__.cpython-38.pyc b/bbcli/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 03ff31385bb1d05e3907f5bcfddf9136938361a8..0000000000000000000000000000000000000000 Binary files a/bbcli/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/bbcli/__pycache__/__main__.cpython-38.pyc b/bbcli/__pycache__/__main__.cpython-38.pyc deleted file mode 100644 index 239121a6e6bae800e8b66326c1d18ccf1ce6c731..0000000000000000000000000000000000000000 Binary files a/bbcli/__pycache__/__main__.cpython-38.pyc and /dev/null differ diff --git a/bbcli/__pycache__/cli.cpython-38.pyc b/bbcli/__pycache__/cli.cpython-38.pyc deleted file mode 100644 index 56ca9b0fb311d2f4f601ee8db6500f8685de7ca6..0000000000000000000000000000000000000000 Binary files a/bbcli/__pycache__/cli.cpython-38.pyc and /dev/null differ diff --git a/bbcli/cli.py b/bbcli/cli.py index 0389e531023a3e30efd146ed84868c2342f1e80b..efd4ffb4b66c4e22149d289b63fdc6b2e2e47b7a 100644 --- a/bbcli/cli.py +++ b/bbcli/cli.py @@ -14,6 +14,8 @@ def _version_callback(value: bool) -> None: typer.echo(f"{__app_name__} v{__version__}") raise typer.Exit() + + @app.callback() def main( version: Optional[bool] = typer.Option( diff --git a/bbcli/endpoints.py b/bbcli/endpoints.py index 7a452f14b92b4366b922990adef542825ca616a1..d1d2cfee81bc3e5784257248442353cffa765ac0 100644 --- a/bbcli/endpoints.py +++ b/bbcli/endpoints.py @@ -5,16 +5,16 @@ import pprint import typer #from string_builder import StringBuilder import click +from typing import Optional app = typer.Typer() - -cookies = {'BbRouter': 'expires:1645188702,id:0E5CC03E415FE4459D9F34DDDFC4AEE7,signature:4e8d6fc59c11f744f6350399dc8cdf14f65a2c26d20e7d53c97141749e9056ac,site:f4fe20be-98b0-4ecd-9039-d18ce2989292,timeout:10800,user:15bd75dd85af4f56b31283276eb8da7c,v:2,xsrf:ac218e34-3110-415c-8718-bd0c8c8bcc8c'} +cookies = {'BbRouter': 'expires:1645202601,id:2480855EED2012DA032F19DEE1610883,signature:81a13d5bdf4946a82a632a9035c0f35811f217671da872677b1d1c32e7a3c339,site:f4fe20be-98b0-4ecd-9039-d18ce2989292,timeout:10800,user:15bd75dd85af4f56b31283276eb8da7c,v:2,xsrf:1bea7fee-fa91-4197-991f-1d266fd1ceee'} base_url = 'https://ntnu.blackboard.com/learn/api/public/v1/' @app.command() -def getuser(user_name: str = 'hanswf') -> None: +def getuser(user_name: str = typer.Argument('hanswf', help='Name of the user'))-> None: ''' Get the user. Specify the user_name as an option, or else it will use the default user_name @@ -42,7 +42,7 @@ def getcourse(course_id: str = 'IDATT2900'): @app.command() def getcoursecontents(course_id: str = '_27251_1'): - url = base_url + 'courses/%s/contents' % course_id + url = f'{base_url}courses/{course_id}/contents' x = requests.get(url, cookies=cookies) data = x.json() print(pprint.pprint(data)) diff --git a/tests/test_bbcli.py b/tests/test_bbcli.py index 14c5d1c2b6afb3141af7cb2b6f418622363c9248..8eaa5325b293ce53a3582a5139f1836ae3e88e4e 100644 --- a/tests/test_bbcli.py +++ b/tests/test_bbcli.py @@ -6,7 +6,7 @@ runner = CliRunner() def test_version(): # invokes the command line and checks the version - result = runner.invoke(cli.app, ["--version"]) + result = runner.invoke(cli.app, ['--version']) assert result.exit_code == 0 assert result.output == f"{__app_name__} v{__version__}\n"