def generate(num, prompt_default=True):
p = Problem(num)<EOL>problem_text = p.text<EOL>msg = "<STR_LIT>" % num<EOL>click.confirm(msg, default=prompt_default, abort=True)<EOL>if p.glob:<EOL><INDENT>filename = str(p.file)<EOL>msg = '<STR_LIT>'.format(filename)<EOL>click.confirm(click.style(msg, fg='<STR_LIT>'), abort=True)<EOL><DEDENT>else:<EOL><INDENT>previous_file = Problem(num - <NUM_LIT:1>).file<EOL>prefix = previous_file.prefix if previous_file else '<STR_LIT>'<EOL>filename = p.filename(prefix=prefix)<EOL><DEDENT>header = '<STR_LIT>' % num<EOL>divider = '<STR_LIT:=>' * len(header)<EOL>text = '<STR_LIT:\n>'.join([header, divider, '<STR_LIT>', problem_text])<EOL>content = '<STR_LIT:\n>'.join(['<STR_LIT>', text, '<STR_LIT>'])<EOL>with open(filename, '<STR_LIT:w>') as f:<EOL><INDENT>f.write(content + '<STR_LIT>')<EOL><DEDENT>click.secho('<STR_LIT>'.format(filename), fg='<STR_LIT>')<EOL>if p.resources:<EOL><INDENT>p.copy_resources()<EOL><DEDENT>
Generates Python file for a problem.