'Update city/location info on existing Nmap scan result documents'

def update_city(self, start, stop, locid, create=False):

    updatespec = dict(((('infos.%s' % key), value) for (key, value) in viewitems(self.globaldb.data.location_byid(locid))))
    if ('infos.country_code' in updatespec):
        updatespec['infos.country_name'] = self.globaldb.data.country_name_by_code(updatespec['infos.country_code'])
    for colname in [self.colname_hosts, self.colname_oldhosts]:
        self.db[colname].update(self.searchrange(start, stop), {'$set': updatespec}, multi=True)
