'Applies action specified by user to responses.'

def ProcessAction(self, response):

    action = self.args.action.action_type
    if (action == rdf_file_finder.FileFinderAction.Action.STAT):
        self.state.files_found += 1
        self.SendReply(response)
    elif (self.args.process_non_regular_files or stat.S_ISREG(response.stat_entry.st_mode)):
        self.state.files_found += 1
        if (action == rdf_file_finder.FileFinderAction.Action.HASH):
            hash_file = False
            file_size = response.stat_entry.st_size
            if (file_size > self.args.action.hash.max_size):
                policy = self.args.action.hash.oversized_file_policy
                options = rdf_file_finder.FileFinderHashActionOptions
                if (policy == options.OversizedFilePolicy.SKIP):
                    self.Log('%s    too    large    to    hash,    skipping    according    to    SKIP    policy.    Size=%d', response.stat_entry.pathspec.CollapsePath(), file_size)
                elif (policy == options.OversizedFilePolicy.HASH_TRUNCATED):
                    self.Log('%s    too    large    to    hash,    hashing    its    first    %d    bytes    according    to    HASH_TRUNCATED    policy.    Size=%d', response.stat_entry.pathspec.CollapsePath(), self.args.action.download.max_size, file_size)
                    hash_file = True
            else:
                hash_file = True
            if hash_file:
                self.FingerprintFile(response.stat_entry.pathspec, max_filesize=self.args.action.hash.max_size, request_data=dict(original_result=response))
        elif (action == rdf_file_finder.FileFinderAction.Action.DOWNLOAD):
            fetch_file = False
            file_size = response.stat_entry.st_size
            if (file_size > self.args.action.download.max_size):
                policy = self.args.action.download.oversized_file_policy
                options = rdf_file_finder.FileFinderDownloadActionOptions
                if (policy == options.OversizedFilePolicy.SKIP):
                    self.Log('%s    too    large    to    fetch,    skipping    according    to    SKIP    policy.    Size=%d', response.stat_entry.pathspec.CollapsePath(), file_size)
                elif (policy == options.OversizedFilePolicy.HASH_TRUNCATED):
                    self.Log('%s    too    large    to    fetch,    hashing    its    first    %d    bytes    according    to    HASH_TRUNCATED    policy.    Size=%d', response.stat_entry.pathspec.CollapsePath(), self.args.action.download.max_size, file_size)
                    self.FingerprintFile(response.stat_entry.pathspec, max_filesize=self.args.action.download.max_size, request_data=dict(original_result=response))
                elif (policy == 'DOWNLOAD_TRUNCATED'):
                    fetch_file = True
            else:
                fetch_file = True
            if fetch_file:
                self.StartFileFetch(response.stat_entry.pathspec, request_data=dict(original_result=response))
