@gen.engine
def Scan(client, table, callback):
 found_entries = {}
 for prefix in options.options.hash_key_prefixes:
  found_entries[prefix] = 0
 deleted = 0
 last_key = None
 count = 0
 while True:
  result = (yield gen.Task(client.Scan, table.name, attributes=None, limit=50, excl_start_key=last_key))
  count += len(result.items)
  for item in result.items:
   value = item.get('t', None)
   sort_key = item.get('k', None)
   if ((value is None) or (sort_key is None)):
    continue
   for prefix in options.options.hash_key_prefixes:
    if value.startswith(prefix):
     logging.info(('matching item: %r' % item))
     found_entries[prefix] += 1
     if options.options.delete:
      logging.info(('deleting item: %r' % item))
      (yield gen.Task(client.DeleteItem, table=table.name, key=db_client.DBKey(value, sort_key)))
      deleted += 1
  if result.last_key:
   last_key = result.last_key
  else:
   break
 logging.info(('Found entries: %r' % found_entries))
 logging.info(('scanned %d items, deleted %d' % (count, deleted)))
 callback()

@ gen . engine def Scan ( client , table , callback ) : found_entries = { } for prefix in options . options . hash_key_prefixes : found_entries [ prefix ] = 0 deleted = 0 last_key = None count = 0 while True : result = ( yield gen . Task ( client . Scan , table . name , attributes = None , limit = 50 , excl_start_key = last_key ) ) count += len ( result . items ) for item in result . items : value = item . get ( 't' , None ) sort_key = item . get ( 'k' , None ) if ( ( value is None ) or ( sort_key is None ) ) : continue for prefix in options . options . hash_key_prefixes : if value . startswith ( prefix ) : logging . info ( ( 'matching item: %r' % item ) ) found_entries [ prefix ] += 1 if options . options . delete : logging . info ( ( 'deleting item: %r' % item ) ) ( yield gen . Task ( client . DeleteItem , table = table . name , key = db_client . DBKey ( value , sort_key ) ) ) deleted += 1 if result . last_key : last_key = result . last_key else : break logging . info ( ( 'Found entries: %r' % found_entries ) ) logging . info ( ( 'scanned %d items, deleted %d' % ( count , deleted ) ) ) callback ( )
scans an entire table .