def test_do_for_all_objects_empty_bucket(): client = setup_client() called = 0 def callback(): nonlocal called called += 1 do_for_all_objects(client, 'Aap', None, callback) assert called == 0
def test_do_for_all_objects_one_object(): client = setup_client() client.put_object(Body='Hello world', Bucket='Aap', Key='noot.txt') called = 0 def callback(_): nonlocal called called += 1 do_for_all_objects(client, 'Aap', None, callback) assert called == 1
def inventory(bucket, symlink_file, prefix): """List inventory from Bucket""" try: client = boto3.client('s3') if symlink_file: def print_callback(data): print(data, end='') _load_from_symlink_file(client, bucket, symlink_file, print_callback) else: do_for_all_objects(client, bucket, prefix, _get_callback(bucket)) except (ClientError, NoCredentialsError) as e: logging.error(e)
def _tag_objects(client, bucket, prefix, tagset): do_for_all_objects(client, bucket, prefix, _get_callback(client, bucket, tagset))