'Adds the cpe in self._curdata to the host-wide cpe list, taking
port/script/osmatch context into account.'

def _add_cpe_to_host(self):

    cpe = self._curdata
    self._curdata = None
    path = None
    if (self._curport is not None):
        if ((self._curscript is not None) and ('id' in self._curscript)):
            path = ('ports{port:%s,    scripts.id:%s}' % (self._curport['port'], self._curscript['id']))
        else:
            path = ('ports.port:%s' % self._curport['port'])
    elif ((self._curscript is not None) and ('id' in self._curscript)):
        path = ('scripts.id:%s' % self._curscript['id'])
    elif (('os' in self._curhost) and self._curhost['os'].get('osmatch', [])):
        lastosmatch = self._curhost['os']['osmatch'][(-1)]
        line = lastosmatch['line']
        path = ('os.osmatch.line:%s' % line)
    cpes = self._curhost.setdefault('cpes', {})
    if (cpe not in cpes):
        try:
            cpeobj = cpe2dict(cpe)
        except ValueError:
            utils.LOGGER.warning('Invalid    cpe    format    (%s)', cpe)
            return
        cpes[cpe] = cpeobj
    else:
        cpeobj = cpes[cpe]
    cpeobj.setdefault('origins', []).append(path)
