Beispiel #1
0
def main():
    parser = argparse.ArgumentParser(parents=[tools.argparser])
    parser.add_argument('-n',
                        '--new-creds',
                        action='store_true',
                        default=False,
                        help="Clear previously saved Google credentials")
    cms_group = parser.add_mutually_exclusive_group()
    cms_group.add_argument('-s',
                           '--skip-cms',
                           action='store_true',
                           default=False,
                           help="Skip enrolling to CMS courses")
    cms_group.add_argument('-o',
                           '--only-cms',
                           action='store_true',
                           default=False,
                           help="Only enrol to CMS courses")
    args = parser.parse_args()

    if not args.only_cms:
        gcal = GCal(args.new_creds)
        set_cal(gcal)

    reg_sections = erp.get_reg_sections()
    print("Fetched registered courses from ERP.")
    final_secions = override_sections(reg_sections)

    for course_code, sections in final_secions.items():
        course = get_course(course_code, sections)
        if not args.skip_cms:
            enrol_cms(course_code, sections)
        if not args.only_cms:
            for event in make_course_events(course):
                gcal.create_event(event)
                gcal.print_event(event, "Created", "in GCal.")