def parse_apps(apps_xml):
    obj = xmltodict.parse(apps_xml)
    try:
        apps = obj['response']['result']['application']['entry']
    except KeyError as e:
        logger.error("Unable to parse app xml from firewall")
        raise e
    csv_apps = []
    for app in apps:
        a = OrderedDict()
        try:
            a['app'] = app['@name']
            a['app:category'] = app.get('category', "")
            a['app:subcategory'] = app.get('subcategory', "")
            a['app:technology'] = app.get('technology', "")
            a['app:risk'] = app['risk']
            a['app:evasive'] = app['evasive-behavior']
            a['app:excessive_bandwidth'] = app['consume-big-bandwidth']
            a['app:used_by_malware'] = app['used-by-malware']
            a['app:able_to_transfer_file'] = app['able-to-transfer-file']
            a['app:has_known_vulnerability'] = app['has-known-vulnerability']
            a['app:tunnels_other_application'] = app['tunnel-other-application']
            if a['app:tunnels_other_application'] != u"yes" and a['app:tunnels_other_application'] != u"no":
                a['app:tunnels_other_application'] = a['app:tunnels_other_application']['#text']
            a['app:prone_to_misuse'] = app['prone-to-misuse']
            a['app:pervasive_use'] = app['pervasive-use']
            a['app:is_saas'] = app.get('is-saas', "no")
            a['app:default_ports'] = ""
            try:
                # Sometimes there are more than one default tag
                # so make it a list and iterate over the default tags.
                default = app['default']
                if isinstance(default, list):
                    for d in default:
                        a['app:default_ports'] = d['port']['member']
                        break
                else:
                    a['app:default_ports'] = default['port']['member']
            except KeyError:
                pass
            else:
                if not isinstance(a['app:default_ports'], basestring):
                    a['app:default_ports'] = "|".join(a['app:default_ports'])
        except Exception as e:
            logger.error("Error parsing app: %s" % app['@name'])
            logger.error(traceback.format_exc())
            common.exit_with_error(str(e))
        # convert all out of unicode
        for key in a:
            a[key] = str(a[key])
        csv_apps.append(a)
    logger.info(len(csv_apps) % "Found %s apps")
    return csv_apps
dataset/ETHPy150Open PaloAltoNetworks/SplunkforPaloAltoNetworks/bin/panContentPack.py/parse_apps/swapped operands of `%`