lms .cli .courses .syllabus .get
Get a course's syllabus.
usage: python3 -m lms.cli.courses.syllabus.get [-h] [--version]
[--server SERVER]
[--server-type {blackboard,canvas,moodle}]
[--auth-user AUTH_USER]
[--auth-password AUTH_PASSWORD]
[--auth-token AUTH_TOKEN]
[--course COURSE]
Get a course's syllabus.
options:
-h, --help show this help message and exit
--version show program's version number and exit
--course COURSE The course to target for this operation.
server options:
--server SERVER The address of the LMS server to connect to.
--server-type {blackboard,canvas,moodle}
The type of LMS being connected to (this can normally
be guessed from the server address).
authentication options:
--auth-user AUTH_USER
The user to authenticate with.
--auth-password AUTH_PASSWORD
The password to authenticate with.
--auth-token AUTH_TOKEN
The token to authenticate with.
1""" 2Get a course's syllabus. 3""" 4 5import argparse 6import sys 7 8import lms.backend.instance 9import lms.cli.common 10import lms.cli.parser 11 12def run_cli(args: argparse.Namespace) -> int: 13 """ Run the CLI. """ 14 15 config = args._config 16 17 backend = lms.backend.instance.get_backend(**config) 18 19 course_query = lms.cli.common.check_required_course(backend, config) 20 if (course_query is None): 21 return 1 22 23 syllabus = backend.courses_syllabus_get(course_query) 24 25 if (syllabus is None): 26 print(f"<No syllabus found for course: '{course_query}'.>") 27 else: 28 print(syllabus) 29 30 return 0 31 32def main() -> int: 33 """ Get a parser, parse the args, and call run. """ 34 return run_cli(_get_parser().parse_args()) 35 36def _get_parser() -> argparse.ArgumentParser: 37 """ Get the parser. """ 38 39 parser = lms.cli.parser.get_parser(__doc__.strip(), 40 include_course = True, 41 ) 42 43 return parser 44 45if (__name__ == '__main__'): 46 sys.exit(main())
def
run_cli(args: argparse.Namespace) -> int:
13def run_cli(args: argparse.Namespace) -> int: 14 """ Run the CLI. """ 15 16 config = args._config 17 18 backend = lms.backend.instance.get_backend(**config) 19 20 course_query = lms.cli.common.check_required_course(backend, config) 21 if (course_query is None): 22 return 1 23 24 syllabus = backend.courses_syllabus_get(course_query) 25 26 if (syllabus is None): 27 print(f"<No syllabus found for course: '{course_query}'.>") 28 else: 29 print(syllabus) 30 31 return 0
Run the CLI.
def
main() -> int:
33def main() -> int: 34 """ Get a parser, parse the args, and call run. """ 35 return run_cli(_get_parser().parse_args())
Get a parser, parse the args, and call run.