def safe_process_files(path, files, args, state):
for fn in files:<EOL><INDENT>full_fn = os.path.join(path, fn)<EOL>try:<EOL><INDENT>if not process_file(path, fn, args, state):<EOL><INDENT>return False<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>sys.stderr.write("<STR_LIT>" % (os.path.join(path, fn), traceback.format_exc()))<EOL>state.log_failed(full_fn)<EOL><DEDENT>if state.should_quit():<EOL><INDENT>return False<EOL><DEDENT><DEDENT>return True<EOL>
Process a number of files in a directory. Catches any exception from the
processing and checks if we should fail directly or keep going.