示例#1
0
文件: cache.py 项目: imclab/oxtail
 def fetch(entity):
     if verbose: print 'Fetching record for %s %s (%s)...' % (entity['type'], entity['name'], entity['id'])
     try:
         record = generate_entity_data(entity['id'], skip_frequent=True)
         if not record:
             raise Exception()
         write(entity['id'], record['crp_id'] if record['crp_id'] else '', normalize_list([entity['name']] + entity['aliases'], entity['type']), record)
     except:
         if verbose: print 'Warning: unable to fetch record for %s %s (%s).' % (entity['type'], entity['name'], entity['id'])
示例#2
0
    def handle(self, *args, **options):
        for arg in args:
            entity_id = arg.replace('-', '')
            entity = Entity.objects.get(pk=entity_id)
            data = generate_entity_data(td_id=entity_id)
            aliases = normalize(data['raw_name'], data['type'])

            entity.json = json.dumps(data)
            entity.aliases = aliases

            print "Saving %s with aliases %s" % (entity.id, json.dumps(entity.aliases))

            entity.save()
示例#3
0
 def fetch(entity):
     if verbose:
         print 'Fetching record for %s %s (%s)...' % (
             entity['type'], entity['name'], entity['id'])
     try:
         record = generate_entity_data(entity['id'], skip_frequent=True)
         if not record:
             raise Exception()
         write(
             entity['id'], record['crp_id'] if record['crp_id'] else '',
             normalize_list([entity['name']] + entity['aliases'],
                            entity['type']), record)
     except:
         if verbose:
             print 'Warning: unable to fetch record for %s %s (%s).' % (
                 entity['type'], entity['name'], entity['id'])