1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import sys
- import aggregator
- from backends.support import ResourceCategory, ResourceRawHTML
- config = {
- "Email": sys.argv[2],
- "Username": sys.argv[2],
- "Password": sys.argv[3],
- "School": sys.argv[4]
- }
- backend = aggregator.load_backend(sys.argv[1])
- if not aggregator.authenticate(backend, config):
- print("Authentication failed")
- sys.exit(1)
- def dump_resources(rsrc, count):
- if isinstance(rsrc, ResourceCategory):
- print((" " * count) + rsrc.name)
- for child in rsrc.children:
- dump_resources(child, count + 1)
- if rsrc.name == "Welcome":
- for child in rsrc.contents:
- dump_resources(child, count + 1)
- elif isinstance(rsrc, ResourceRawHTML):
- print((" " * count) + rsrc.name + ": " + rsrc.html)
- else:
- print((" " * count) + rsrc.name + " (" + type(rsrc).__name__ + ")")
- for course in backend.courses:
- print(course.title + " by " + course.teacher + " (ID " + course.id + ")")
- try:
- print("Course grade: " + str(course.grade_summary))
- if course.title == "TODO: Don't waste bandwidth":
- for category in course.grades:
- print(category.name + ": " + str(round(category.mean * 100)) + "%")
- for grade in category.grades:
- print(".. " + grade.name + ": " + str(round(grade.grade * 100)) + "%")
- except AttributeError:
- print("Backend does not implement grades")
- try:
- dump_resources(course.resources, 0)
- except AttributeError:
- print("Backend does not implement resources")
- try:
- for task in course.tasks:
- print("- " + task.name)
- print(task.resources)
- except AttributeError:
- print("Backend does not implement tasks")
- print("----")
|