human
Complete the below
def _OnScan(final_cb, client, count, scan_result):

    ''''Processes each photo from scan.'
    '''
assistant
#Here is the Python code you requested.
    max_count = int(options.options.limit)
    (photos, last_key) = scan_result
    if (options.options.limit and ((count + len(photos)) > max_count)):
        photos = photos[:(max_count - count)]
    logging.info(('processing    next    %d    photos' % len(photos)))
    count += len(photos)
    obj_store = ObjectStore.GetInstance(ObjectStore.PHOTO)
    pending = deque(photos)
    inflight = set()
    def _OnSinkPhotoGet(ak, nak, callback, source_bytes, sink_bytes):
        'Verifies    that    the    source    and    sink    bytes    match.'
        logging.info(('got    sink    photo    %s:    %d    bytes' % (nak, len(sink_bytes))))
        inflight.remove(ak)
        if (source_bytes != sink_bytes):
            logging.error("source    and    sink    bytes    don't    match!    deleting    sink    to    retry")
            obj_store.Delete(nak, callback)
            return
        logging.info(('verified    %s    =>    %s' % (ak, nak)))
        if options.options.REALLY_DELETE_OLD:
            logging.info(('deleting    %s' % ak))
            obj_store.Delete(ak, callback)
        else:
            callback()
    def _OnPhotoPut(ak, nak, callback, photo_bytes):
        'Removes    the    asset    from    inflight    map.'
        logging.info(('copied    %s    =>    %s' % (ak, nak)))
        if options.options.verify_files:
            obj_store.Get(nak, partial(_OnSinkPhotoGet, ak, nak, callback, photo_bytes))
        else:
            inflight.remove(ak)
            callback()
    def _OnErrorSinkGet(ak, nak, callback, photo_bytes, type, value, tb):
        if options.options.copy_files:
            logging.info('copying...')
            obj_store.Put(nak, photo_bytes, partial(_OnPhotoPut, ak, nak, callback, photo_bytes), content_type=_CONTENT_TYPE)
        else:
            logging.warning(('old-suffix    photo    asset    has    not    been    copied:    %s' % ak))
            inflight.remove(ak)
            callback()
    def _OnPhotoGet(ak, nak, callback, photo_bytes):
        'Get    the    sink   ...