'Parse the rpm -qa output.'

def Parse(self, cmd, args, stdout, stderr, return_val, time_taken, knowledge_base):

    _ = (time_taken, args, knowledge_base)
    rpm_re = re.compile('^(\\w[-\\w\\+]+?)-(\\d.*)$')
    self.CheckReturn(cmd, return_val)
    for line in stdout.splitlines():
        pkg_match = rpm_re.match(line.strip())
        if pkg_match:
            (name, version) = pkg_match.groups()
            status = rdf_client.SoftwarePackage.InstallState.INSTALLED
            (yield rdf_client.SoftwarePackage(name=name, version=version, install_state=status))
    for line in stderr.splitlines():
        if ('error:    rpmdbNextIterator:    skipping    h#' in line):
            (yield rdf_anomaly.Anomaly(type='PARSER_ANOMALY', symptom='Broken    rpm    database.'))
            break
