def parse_threats(threats_xml):
    obj = xmltodict.parse(threats_xml)
    try:
        phone_home = obj['response']['result']['threats']['phone-home']['entry']
        vulnerability = obj['response']['result']['threats']['vulnerability']['entry']
        threats = phone_home + vulnerability
    except KeyError as e:
        logger.error("Unable to parse threat xml from firewall")
        raise e
    csv_threats = []
    for threat in threats:
        a = OrderedDict()
        try:
            a['threat_id'] = threat['@name']
            a['threat:name'] = threat['threatname']
            a['threat:category'] = threat['category']
            a['threat:severity'] = threat['severity']
            a['threat:cve'] = threat.get('cve', None)
            if a['threat:cve'] is not None:
                a['threat:cve'] = threat['cve']['member']
                if not isinstance(a['threat:cve'], basestring):
                    a['threat:cve'] = ", ".join(a['threat:cve'])
            else:
                a['threat:cve'] = ""
        except KeyError as e:
            logger.error(threat['@name'] % "Error parsing app: %s")
            raise e
        # convert all out of unicode
        for key in a:
            a[key] = str(a[key])
        csv_threats.append(a)
    logger.info("Found %s threats" % len(csv_threats))
    return csv_threats
dataset/ETHPy150Open PaloAltoNetworks/SplunkforPaloAltoNetworks/bin/panContentPack.py/parse_threats/swapped operands of `%`