@log_calls<EOL><INDENT>def batch_delete(self, sources):<DEDENT>
assert(type(sources) == list)<EOL>if len(sources) == <NUM_LIT:0>:<EOL><INDENT>return<EOL><DEDENT>elif len(sources) == <NUM_LIT:1>:<EOL><INDENT>self.delete(sources[<NUM_LIT:0>])<EOL><DEDENT>elif len(sources) > self.opt.batch_delete_size:<EOL><INDENT>for i in range(<NUM_LIT:0>, len(sources), self.opt.batch_delete_size):<EOL><INDENT>self.pool.batch_delete(sources[i:i+self.opt.batch_delete_size])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>bucket = S3URL(sources[<NUM_LIT:0>]).bucket<EOL>deletes = []<EOL>for source in sources:<EOL><INDENT>s3url = S3URL(source)<EOL>if s3url.bucket != bucket:<EOL><INDENT>raise Failure('<STR_LIT>' % (s3url.bucket, bucket))<EOL><DEDENT>deletes.append({'<STR_LIT>': s3url.path})<EOL><DEDENT>response = self.s3.delete_objects(Bucket=bucket, Delete={'<STR_LIT>': deletes})<EOL>for res in response.get('<STR_LIT>') or []:<EOL><INDENT>message('<STR_LIT>', S3URL.combine('<STR_LIT>', bucket, res['<STR_LIT>']))<EOL><DEDENT>for err in response.get('<STR_LIT>') or []:<EOL><INDENT>message('<STR_LIT>', S3URL.combine('<STR_LIT>', bucket, res['<STR_LIT>']), err['<STR_LIT>'], err['<STR_LIT>'])<EOL><DEDENT>if response.get('<STR_LIT>') is not None:<EOL><INDENT>raise RetryFailure('<STR_LIT>' % len(response.get('<STR_LIT>')))<EOL><DEDENT><DEDENT>
Delete a list of files in batch of batch_delete_size (default=1000).