#NEWLINE# def clean_up_caches( ctx , directory , images_info ) : #NEWLINE# #INDENT# 'Explicitly cleanup caches based on their priority (if required).\n\n    This cleans up the caches to free up the amount of space required for the\n    images in images_info. The caches are cleaned up one after the other in\n    the order of their priority.  If we still cannot free up enough space\n    after trying all the caches, this method throws exception.\n\n    :param ctx: context\n    :param directory: the directory (of the cache) to be freed up.\n    :param images_info: a list of tuples of the form (image_uuid,path)\n        for which space is to be created in cache.\n    :raises: InsufficientDiskSpace exception, if we cannot free up enough space\n    after trying all the caches.\n    ' #NEWLINE# total_size = sum ( ( images . download_size ( ctx , images_info ) for ( uuid , path ) in images_info ) ) #NEWLINE# _clean_up_caches ( directory , total_size )