'Create a set of host_data results based on file parser results.
Creates a host data result populated with a knowledge base, then processes
each piece of host data as if it were file results using a parser. Specific
stat values can be provided to the parser, if required, so that permissions,
ownership and file types can be defined.
Args:
artifact: The artifact name that generated data will be mapped to.
data: A dictionary of pathnames and data strings. The data strings are
converted into file objects for the parser.
parser: The FileParser that processes the data (and stats)
modes: A dictionary of pathnames and stat values. Stat values are a dict
of {st_uid: int, st_gid: int, st_mode: oct} entries.
include: A list of pathnames to include in processing. If not provided,
all paths are parsed.
Returns:
the host_data map populated with a knowledge base and artifact data.
Raises:
Error: When the handed parser was not initialized.'

def GenFileData(self, artifact, data, parser=None, modes=None, include=None):

    host_data = self.SetKnowledgeBase()
    if (not parser):
        raise test_lib.Error('Test    method    requires    an    initialized    parser.')
    if (not modes):
        modes = {}
    kb = host_data['KnowledgeBase']
    files = []
    rdfs = []
    stats = []
    for path in data:
        if (include and (path not in include)):
            continue
        file_modes = modes.get(path, {})
        (stats, files) = self._GenFileData([path], [data[path]], stats=stats, files=files, modes=file_modes)
    if parser.process_together:
        rdfs = list(parser.ParseMultiple(stats, files, kb))
    else:
        for (stat, file_obj) in zip(stats, files):
            rslt = (parser.Parse(stat, file_obj, kb) or [])
            rdfs.extend(rslt)
    anomaly = [a for a in rdfs if isinstance(a, rdf_anomaly.Anomaly)]
    parsed = [r for r in rdfs if (not isinstance(r, rdf_anomaly.Anomaly))]
    host_data[artifact] = self.SetArtifactData(parsed=parsed, anomaly=anomaly, raw=stats)
    return host_data
