#NEWLINE# def remove( self , file_handle_id , path = None , delete = None ) : #NEWLINE# #INDENT# '\n        Remove a file from the cache.\n\n        :param file_handle_id: Will also extract file handle id from either a File or file handle\n        :param path: If the given path is None, remove (and potentially delete)\n                     all cached copies. If the path is that of a file in the\n                     .cacheMap file, remove it.\n\n        :returns: A list of files removed\n        ' #NEWLINE# removed = [ ] #NEWLINE# cache_dir = self . get_cache_dir ( file_handle_id ) #NEWLINE# if ( ( path is None ) and isinstance ( file_handle_id , collections . Mapping ) and ( 'path' in file_handle_id ) ) : #NEWLINE# #INDENT# path = file_handle_id [ 'path' ] #NEWLINE# #UNINDENT# with Lock ( self . cache_map_file_name , dir = cache_dir ) : #NEWLINE# #INDENT# cache_map = self . _read_cache_map ( cache_dir ) #NEWLINE# if ( path is None ) : #NEWLINE# #INDENT# for path in cache_map : #NEWLINE# #INDENT# if ( ( delete is True ) and os . path . exists ( path ) ) : #NEWLINE# #INDENT# os . remove ( path ) #NEWLINE# #UNINDENT# removed . append ( path ) #NEWLINE# #UNINDENT# cache_map = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# path = utils . normalize_path ( path ) #NEWLINE# if ( path in cache_map ) : #NEWLINE# #INDENT# if ( ( delete is True ) and os . path . exists ( path ) ) : #NEWLINE# #INDENT# os . remove ( path ) #NEWLINE# #UNINDENT# del cache_map [ path ] #NEWLINE# removed . append ( path ) #NEWLINE# #UNINDENT# #UNINDENT# self . _write_cache_map ( cache_dir , cache_map ) #NEWLINE# #UNINDENT# return removed