#NEWLINE# def main( ) : #NEWLINE# #INDENT# parser = argparse . ArgumentParser ( description = '{} problem manager' . format ( api . config . competition_name ) ) #NEWLINE# debug_level = parser . add_mutually_exclusive_group ( ) #NEWLINE# debug_level . add_argument ( '-v' , '--verbose' , help = 'Print intermediate results' , action = 'store_true' ) #NEWLINE# debug_level . add_argument ( '-s' , '--silent' , help = 'Print out very little' , action = 'store_true' ) #NEWLINE# subparser = parser . add_subparsers ( help = 'Select one of the following actions' ) #NEWLINE# parser_autogen = subparser . add_parser ( 'autogen' , help = 'Deal with Problem Autogeneration' ) #NEWLINE# subparser_autogen = parser_autogen . add_subparsers ( help = 'Select one of the following actions' ) #NEWLINE# parser_autogen_build = subparser_autogen . add_parser ( 'build' , help = 'Build new autogen instances' ) #NEWLINE# parser_autogen_build . add_argument ( 'instance_count' , type = int , help = 'How many instances of each problem to build' ) #NEWLINE# parser_autogen_build . set_defaults ( func = build_autogen ) #NEWLINE# parser_problems = subparser . add_parser ( 'problems' , help = 'Deal with Problems' ) #NEWLINE# subparser_problems = parser_problems . add_subparsers ( help = 'Select one of the following actions' ) #NEWLINE# parser_problems_import = subparser_problems . add_parser ( 'import' , help = 'Import problems (from JSON) into the database' ) #NEWLINE# parser_problems_import . add_argument ( 'files' , nargs = '+' , help = 'Files containing problems to insert.' ) #NEWLINE# parser_problems_import . set_defaults ( func = add_new_problems ) #NEWLINE# parser_problems_load = subparser_problems . add_parser ( 'load' , help = 'Load problems that follow the special problem format' ) #NEWLINE# parser_problems_load . add_argument ( 'problems_directory' , nargs = 1 , help = 'Directory where problems are located' ) #NEWLINE# parser_problems_load . add_argument ( 'graders_directory' , nargs = 1 , help = 'Directory where graders are stored' ) #NEWLINE# parser_problems_load . add_argument ( 'static_directory' , nargs = 1 , help = 'Directory where static problem content is stored' ) #NEWLINE# parser_problems_load . set_defaults ( func = load_problems ) #NEWLINE# parser_problems_list = subparser_problems . add_parser ( 'list' , help = 'List problems in the database' ) #NEWLINE# parser_problems_list . set_defaults ( func = list_problems ) #NEWLINE# parser_problems_migrate = subparser_problems . add_parser ( 'migrate' , help = 'Migrate 2013 problems to the new format' ) #NEWLINE# parser_problems_migrate . add_argument ( '-o' , '--output' , action = 'store' , help = 'Output file.' , default = sys . stdout ) #NEWLINE# parser_problems_migrate . set_defaults ( func = migrate_problems ) #NEWLINE# parser_achievements = subparser . add_parser ( 'achievements' , help = 'Deal with Achievements' ) #NEWLINE# subparser_achievements = parser_achievements . add_subparsers ( help = 'Select one of the following actions' ) #NEWLINE# parser_achievements_load = subparser_achievements . add_parser ( 'load' , help = 'Load new achievements into the database' ) #NEWLINE# parser_achievements_load . add_argument ( 'files' , nargs = '+' , help = 'Files containing achievements to insert.' ) #NEWLINE# parser_achievements_load . set_defaults ( func = add_new_achievements ) #NEWLINE# parser_database = subparser . add_parser ( 'database' , help = 'Deal with database' ) #NEWLINE# subparser_database = parser_database . add_subparsers ( help = 'Select one of the following actions' ) #NEWLINE# parser_database_clear = subparser_database . add_parser ( 'clear' , help = 'Clear collections' ) #NEWLINE# parser_database_clear . add_argument ( 'collections' , nargs = '+' , help = 'Collections to clear' ) #NEWLINE# parser_database_clear . set_defaults ( func = clear_collections ) #NEWLINE# parser_team = subparser . add_parser ( 'team' , help = 'Deal with team' ) #NEWLINE# subparser_team = parser_team . add_subparsers ( help = 'Select one of the following actions' ) #NEWLINE# parser_team_clear = subparser_team . add_parser ( 'eligibility' , help = 'Recalculate Eligibility' ) #NEWLINE# parser_team_clear . set_defaults ( func = recalculate_eligibility ) #NEWLINE# parser_user = subparser . add_parser ( 'user' , help = 'Deal with user' ) #NEWLINE# subparser_user = parser_user . add_subparsers ( help = 'Select one of the following actions' ) #NEWLINE# parser_user_password = subparser_user . add_parser ( 'password' , help = 'Change user password' ) #NEWLINE# parser_user_password . add_argument ( 'user' , help = 'user' ) #NEWLINE# parser_user_password . add_argument ( 'password' , help = 'New user password' ) #NEWLINE# parser_user_password . set_defaults ( func = change_user_password ) #NEWLINE# parser_stats = subparser . add_parser ( 'stats' , help = 'Deal with stats' ) #NEWLINE# subparser_stats = parser_stats . add_subparsers ( help = 'Select one of the following actions' ) #NEWLINE# parser_stats_clear = subparser_stats . add_parser ( 'show' , help = 'Display stats' ) #NEWLINE# parser_stats_clear . set_defaults ( func = get_stats ) #NEWLINE# args = parser . parse_args ( ) #NEWLINE# if subparser_database . silent : #NEWLINE# #INDENT# logging . basicConfig ( level = logging . CRITICAL , stream = sys . stdout ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if args . verbose : #NEWLINE# #INDENT# logging . basicConfig ( level = logging . DEBUG , stream = sys . stdout ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logging . basicConfig ( level = logging . WARNING , stream = sys . stdout ) #NEWLINE# #UNINDENT# #UNINDENT# if ( 'func' in args ) : #NEWLINE# #INDENT# args . func ( args ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# parser . print_help ( )