#NEWLINE# def make_random_contest( ballot_count , candidate_count , format_cls , json_contests_path , output_dir , normalize = True , stdout = None ) : #NEWLINE# #INDENT# 'Generate a random contest.' #NEWLINE# if ( stdout is None ) : #NEWLINE# #INDENT# stdout = sys . stdout #NEWLINE# #UNINDENT# format = format_cls ( ) #NEWLINE# creator = contestgen . ContestCreator ( ) #NEWLINE# with temp_ballots_resource ( ) as ballots_resource : #NEWLINE# #INDENT# contest = creator . create_random ( ballots_resource , ballot_count = ballot_count , candidate_count = candidate_count ) #NEWLINE# if normalize : #NEWLINE# #INDENT# contest . ballots_resource . normalize ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# contest . normalize_ballots = False #NEWLINE# #UNINDENT# output_paths = format . write_contest ( contest , output_dir = output_dir , stdout = stdout ) #NEWLINE# if json_contests_path : #NEWLINE# #INDENT# jcmanage . add_contest_to_contests_file ( contest , json_contests_path ) #NEWLINE# #UNINDENT# #UNINDENT# return ( ( '\n' . join ( output_paths ) + '\n' ) if output_paths else None )