def main(argv=None):
parser = argparse.ArgumentParser(description=DESCRIPTION, epilog=EPILOG)<EOL>parser.add_argument(<EOL>'<STR_LIT>', '<STR_LIT>', help='<STR_LIT>', action='<STR_LIT:store_true>'<EOL>)<EOL>parser.add_argument(<EOL>'<STR_LIT>', help='<STR_LIT>'<EOL>)<EOL>parser.add_argument(<EOL>'<STR_LIT>', dest='<STR_LIT>', action='<STR_LIT:store_true>',<EOL>help='<STR_LIT>',<EOL>)<EOL>parser.add_argument(<EOL>'<STR_LIT>', metavar='<STR_LIT>', nargs='<STR_LIT:*>', help='<STR_LIT>'<EOL>)<EOL>if argv is None:<EOL><INDENT>args = parser.parse_args()<EOL><DEDENT>else:<EOL><INDENT>args = parser.parse_args(argv)<EOL><DEDENT>if args.format == '<STR_LIT>':<EOL><INDENT>outputter = CSVOutput<EOL><DEDENT>else:<EOL><INDENT>outputter = TextOutput<EOL><DEDENT>api_token = os.environ.get('<STR_LIT>', '<STR_LIT>')<EOL>generator = SignatureGenerator()<EOL>if args.crashids:<EOL><INDENT>crashids_iterable = args.crashids<EOL><DEDENT>elif not sys.stdin.isatty():<EOL><INDENT>crashids_iterable = list(sys.stdin)<EOL><DEDENT>else:<EOL><INDENT>crashids_iterable = []<EOL><DEDENT>if not crashids_iterable:<EOL><INDENT>parser.print_help()<EOL>return <NUM_LIT:0><EOL><DEDENT>with outputter() as out:<EOL><INDENT>for crash_id in crashids_iterable:<EOL><INDENT>crash_id = crash_id.strip()<EOL>resp = fetch('<STR_LIT>', crash_id, api_token)<EOL>if resp.status_code == <NUM_LIT>:<EOL><INDENT>out.warning('<STR_LIT>' % crash_id)<EOL>continue<EOL><DEDENT>if resp.status_code == <NUM_LIT>:<EOL><INDENT>out.warning('<STR_LIT>' % resp.content)<EOL>return <NUM_LIT:1><EOL><DEDENT>if resp.status_code == <NUM_LIT>:<EOL><INDENT>out.warning('<STR_LIT>' % resp.content)<EOL>continue<EOL><DEDENT>raw_crash = resp.json()<EOL>if '<STR_LIT:error>' in raw_crash:<EOL><INDENT>out.warning('<STR_LIT>' % raw_crash['<STR_LIT:error>'])<EOL>return <NUM_LIT:1><EOL><DEDENT>resp = fetch('<STR_LIT>', crash_id, api_token)<EOL>if resp.status_code == <NUM_LIT>:<EOL><INDENT>out.warning('<STR_LIT>' % crash_id)<EOL>continue<EOL><DEDENT>if resp.status_code == <NUM_LIT>:<EOL><INDENT>out.warning('<STR_LIT>' % resp.content)<EOL>return <NUM_LIT:1><EOL><DEDENT>if resp.status_code == <NUM_LIT>:<EOL><INDENT>out.warning('<STR_LIT>' % resp.content)<EOL>continue<EOL><DEDENT>processed_crash = resp.json()<EOL>if '<STR_LIT:error>' in processed_crash:<EOL><INDENT>out.warning('<STR_LIT>' % processed_crash['<STR_LIT:error>'])<EOL>return <NUM_LIT:1><EOL><DEDENT>old_signature = processed_crash['<STR_LIT>']<EOL>crash_data = convert_to_crash_data(raw_crash, processed_crash)<EOL>result = generator.generate(crash_data)<EOL>if not args.different or old_signature != result.signature:<EOL><INDENT>out.data(crash_id, old_signature, result, args.verbose)<EOL><DEDENT><DEDENT><DEDENT>
Takes crash data via args and generates a Socorro signature