def main():
global args<EOL>args = parse_args()<EOL>if not args:<EOL><INDENT>return <NUM_LIT:1><EOL><DEDENT>state = MyState(args)<EOL>for path in args.paths:<EOL><INDENT>if os.path.isdir(path):<EOL><INDENT>walk_dir(path, args, state)<EOL><DEDENT>else:<EOL><INDENT>safe_process_files(os.path.dirname(path), [os.path.basename(path)], args, state)<EOL><DEDENT>if state.should_quit():<EOL><INDENT>break<EOL><DEDENT><DEDENT>if state.failed_files:<EOL><INDENT>sys.stderr.write("<STR_LIT>" % (len(state.failed_files), state.file_count))<EOL>return <NUM_LIT:1><EOL><DEDENT>if args.debug:<EOL><INDENT>sys.stderr.write("<STR_LIT>" % (state.file_count))<EOL><DEDENT>
Main function when running as a program.