Exemple #1
0
def main():
    semester_choices = sorted((semester.code for semester in Semester.all()), reverse=True)
    arg_parser = ArgumentParser()
    arg_parser.add_argument('semester', nargs='?', default=Semester.current_semester().code)
    arg_parser.add_argument('--raw', default=False, action='store_true')
    args = arg_parser.parse_args()
    response = update_db(Semester.from_code(args.semester))
    if args.raw:
        with open('response', 'w') as fd:
            fd.write(response)
Exemple #2
0
def main():
    semester_choices = ('any', *sorted((semester.code for semester in Semester.all()), reverse=True))
    arg_parser = ArgumentParser()
    arg_parser.add_argument('terms', metavar='TERM', nargs='*')
    arg_parser.add_argument('--semester', default=Semester.current_semester().code, choices=semester_choices)
    arg_parser.add_argument('--sort', choices=('semester', 'number', 'title', 'instructors', 'meetings'))
    args = arg_parser.parse_args()
    if args.semester == 'any':
        offerings = OFFERINGS
    else:
        semester = Semester.from_code(args.semester)
        offerings = filter_by_semester(OFFERINGS, semester.code)
    search(offerings, ' '.join(args.terms), sort=args.sort)