'Schedule files for download based on pathspec attribute.
Args:
responses: Response objects from the artifact source.
Raises:
RuntimeError: if pathspec value is not a PathSpec instance and not
a basestring.'

@flow.StateHandler()
def ProcessCollectedArtifactFiles(self, responses):

    self.download_list = []
    source = responses.request_data.GetItem('source')
    pathspec_attribute = source['attributes'].get('pathspec_attribute', None)
    for response in responses:
        if pathspec_attribute:
            if response.HasField(pathspec_attribute):
                pathspec = response.Get(pathspec_attribute)
            else:
                self.Log('Missing    pathspec    field    %s:    %s', pathspec_attribute, response)
                continue
        else:
            pathspec = response
        if (not isinstance(pathspec, paths.PathSpec)):
            try:
                pathspec = response.pathspec
            except AttributeError:
                pass
        if isinstance(pathspec, basestring):
            pathspec = paths.PathSpec(path=pathspec)
            if self.args.use_tsk:
                pathspec.pathtype = paths.PathSpec.PathType.TSK
            else:
                pathspec.pathtype = paths.PathSpec.PathType.OS
            self.download_list.append(pathspec)
        elif isinstance(pathspec, paths.PathSpec):
            self.download_list.append(pathspec)
        else:
            raise RuntimeError(('Response    must    be    a    string    path,    a    pathspec,    or    have    pathspec_attribute    set.    Got:    %s' % pathspec))
    if self.download_list:
        request_data = responses.request_data.ToDict()
        self.CallFlow(transfer.MultiGetFile.__name__, pathspecs=self.download_list, request_data=request_data, next_state='ProcessCollected')
    else:
        self.Log('No    files    to    download')
