#NEWLINE# def delete( self , container = None , objects = None , options = None ) : #NEWLINE# #INDENT# "\n        Delete operations on an account, optional container and optional list\n        of objects.\n\n        :param container: The container to delete or delete from.\n        :param objects: The list of objects to delete.\n        :param options: A dictionary containing options to override the global\n                        options specified during the service object creation::\n\n                            {\n                                'yes_all': False,\n                                'leave_segments': False,\n                                'prefix': None,\n                            }\n\n        :returns: A generator for returning the results of the delete\n                  operations. Each result yielded from the generator is either\n                  a 'delete_container', 'delete_object', 'delete_segment', or\n                  'bulk_delete' dictionary containing the results of an\n                  individual delete operation.\n\n        :raises: ClientException\n        :raises: SwiftError\n        " #NEWLINE# if ( options is not None ) : #NEWLINE# #INDENT# options = dict ( self . _options , ** options ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# options = self . _options #NEWLINE# #UNINDENT# if ( container is not None ) : #NEWLINE# #INDENT# if ( objects is not None ) : #NEWLINE# #INDENT# if options [ 'prefix' ] : #NEWLINE# #INDENT# objects = [ obj for obj in objects if obj . startswith ( options [ 'prefix' ] ) ] #NEWLINE# #UNINDENT# rq = Queue ( ) #NEWLINE# obj_dels = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if self . _should_bulk_delete ( objects ) : #NEWLINE# #INDENT# for obj_slice in n_groups ( objects , self . _options [ 'object_dd_threads' ] ) : #NEWLINE# #INDENT# self . _bulk_delete ( container , obj_slice , options , obj_dels ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . _per_item_delete ( container , objects , options , obj_dels , rq ) #NEWLINE# #UNINDENT# Thread ( target = self . _watch_futures , args = ( obj_dels , rq ) ) . start ( ) #NEWLINE# res = get_from_queue ( rq ) #NEWLINE# while ( res is not None ) : #NEWLINE# #INDENT# ( yield res ) #NEWLINE# if ( options [ 'fail_fast' ] and ( not res [ 'success' ] ) ) : #NEWLINE# #INDENT# for d in obj_dels . keys ( ) : #NEWLINE# #INDENT# d . cancel ( ) #NEWLINE# #UNINDENT# #UNINDENT# res = get_from_queue ( rq ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# for res in self . _delete_container ( container , options ) : #NEWLINE# #INDENT# ( yield res ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if objects : #NEWLINE# #INDENT# raise SwiftError ( 'Objects specified without container' ) #NEWLINE# #UNINDENT# if options [ 'prefix' ] : #NEWLINE# #INDENT# raise SwiftError ( 'Prefix specified without container' ) #NEWLINE# #UNINDENT# if options [ 'yes_all' ] : #NEWLINE# #INDENT# cancelled = False #NEWLINE# containers = [ ] #NEWLINE# for part in self . list ( ) : #NEWLINE# #INDENT# if part [ 'success' ] : #NEWLINE# #INDENT# containers . extend ( ( c [ 'name' ] for c in part [ 'listing' ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise part [ 'error' ] #NEWLINE# #UNINDENT# #UNINDENT# for con in containers : #NEWLINE# #INDENT# if cancelled : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# for res in self . _delete_container ( con , options = options ) : #NEWLINE# #INDENT# ( yield res ) #NEWLINE# if ( ( not cancelled ) and options [ 'fail_fast' ] and ( not containers [ 'success' ] ) ) : #NEWLINE# #INDENT# cancelled = True