#NEWLINE# def parseopts( args ) : #NEWLINE# #INDENT# parser = create_main_parser ( ) #NEWLINE# ( general_options , args_else ) = parser . parse_args ( args ) #NEWLINE# if general_options . version : #NEWLINE# #INDENT# sys . stdout . write ( parser . version ) #NEWLINE# sys . stdout . write ( os . linesep ) #NEWLINE# sys . exit ( ) #NEWLINE# #UNINDENT# if ( ( not args_else ) or ( ( args_else [ 0 ] == 'help' ) and ( len ( args_else ) == 1 ) ) ) : #NEWLINE# #INDENT# parser . print_help ( ) #NEWLINE# sys . exit ( ) #NEWLINE# #UNINDENT# cmd_name = args_else [ 0 ] #NEWLINE# if ( cmd_name not in commands_dict ) : #NEWLINE# #INDENT# guess = get_similar_commands ( args_else ) #NEWLINE# msg = [ ( 'unknown command "%s"' % cmd_name ) ] #NEWLINE# if guess : #NEWLINE# #INDENT# msg . append ( ( 'maybe you meant "%s"' % guess ) ) #NEWLINE# #UNINDENT# raise CommandError ( ' - ' . join ( msg ) ) #NEWLINE# #UNINDENT# cmd_args = args [ : ] #NEWLINE# cmd_args . remove ( cmd_name ) #NEWLINE# return ( cmd_name , cmd_args )