def main(): parser = argparse.ArgumentParser(description="Scraping for Oscar") parser.add_argument( "command", type=command_type, help="One of the following options: %s" % ", ".join(command_list()), nargs="?" ) parser.add_argument( "--term", type=term_type, help='Semester and year such as "summer 2007"' " (defaults to the latest term)", metavar="", ) parser.add_argument("--subject", help='Subject such as "cs" or "comp sci"', metavar="") parser.add_argument("--number", help='Course number such as "1101" or "8803"', metavar="") parser.add_argument( "--course", type=course_type, help='Course such as "CS2110" or "psych 1101" ' "(equivalent to --subject and --number)", metavar="", ) parser.add_argument("--section", help='Section name such as "A" or "B"', metavar="") parser.add_argument("--crn", help="CRN (number that identifies a section)", metavar="") parser.add_argument( "--offline", dest="enable_http", action="store_false", help="Disable network access and use only cached data" ) parser.add_argument( "--refresh", action="store_true", help="Fetch the most recent information from the " "server, regardless of the cache state", ) parser.add_argument("--verbose", action="store_true", help="Print logging output") parser.add_argument( "--quiet", dest="chatty", action="store_false", help="Do not print anything beyond the output " "requested by the command", ) parser.add_argument( "--log-http", dest="log_http", action="store_true", help="Log HTTP requests and responses to disk " "(warning: this could include authentication credentials)", ) args = parser.parse_args() context = Context() if args.chatty: print "" if args.verbose: context.get_logger().addHandler(log_handler()) store = Store(context=context, enable_http=args.enable_http, log_http=args.log_http, force_refresh=args.refresh) if args.subject is not None: subject = store.find_subject(args.subject) args.subject = subject if args.command: args.command(args, store) if args.chatty: print ""
def main(): parser = argparse.ArgumentParser( description='Scraping for Oscar' ) parser.add_argument( 'command', type=command_type, help='One of the following options: %s' \ % ', '.join(command_list()), nargs='?', ) parser.add_argument( '--term', type=term_type, help='Semester and year such as "summer 2007"' \ ' (defaults to the latest term)', metavar='', ) parser.add_argument( '--subject', help='Subject such as "cs" or "comp sci"', metavar='', ) parser.add_argument( '--number', help='Course number such as "1101" or "8803"', metavar='', ) parser.add_argument( '--course', type=course_type, help='Course such as "CS2110" or "psych 1101" ' '(equivalent to --subject and --number)', metavar='', ) parser.add_argument( '--section', help='Section name such as "A" or "B"', metavar='', ) parser.add_argument( '--crn', help='CRN (number that identifies a section)', metavar='', ) parser.add_argument( '--offline', dest='enable_http', action='store_false', help='Disable network access and use only cached data', ) parser.add_argument( '--refresh', action='store_true', help='Fetch the most recent information from the ' \ 'server, regardless of the cache state' ) parser.add_argument( '--verbose', action='store_true', help='Print logging output', ) parser.add_argument( '--quiet', dest='chatty', action='store_false', help='Do not print anything beyond the output ' 'requested by the command', ) parser.add_argument( '--log-http', dest='log_http', action='store_true', help='Log HTTP requests and responses to disk ' '(warning: this could include authentication credentials)', ) args = parser.parse_args() context = Context() if args.chatty: print('') if args.verbose: context.get_logger().addHandler(log_handler()) store = Store( context=context, enable_http=args.enable_http, log_http=args.log_http, force_refresh=args.refresh, ) if args.subject is not None: subject = store.find_subject(args.subject) args.subject = subject if args.command: args.command(args, store) if args.chatty: print('')