'Sets the `screenwords` attribute based on the screenshot
data.'

def setscreenwords(self, host, port=None, protocol='tcp', archive=False, overwrite=False):

    if (port is None):
        if overwrite:
            flt_cond = (lambda p: ('screenshot' in p))
        else:
            flt_cond = (lambda p: (('screenshot' in p) and ('screenwords' not in p)))
    elif overwrite:
        flt_cond = (lambda p: (('screenshot' in p) and (p.get('port') == port) and (p.get('protocol') == protocol)))
    else:
        flt_cond = (lambda p: (('screenshot' in p) and ('screenwords' not in p) and (p.get('port') == port) and (p.get('protocol') == protocol)))
    updated = False
    for port in host.get('ports', []):
        if (not flt_cond(port)):
            continue
        screenwords = utils.screenwords(self.getscreenshot(port))
        if (screenwords is not None):
            port['screenwords'] = screenwords
            updated = True
    if updated:
        self.db[(self.colname_oldhosts if archive else self.colname_hosts)].update({'_id': host['_id']}, {'$set': {'ports': host['ports']}})
