

def remove_intermediate_files(index_stacker, stack_info_dict):
    ' Function to remove intermediate band files after stats have been computed\n        '
    removed_file_count = 0
    for vrt_stack_path in sorted(stack_info_dict.keys()):
        stack_list = stack_info_dict[vrt_stack_path]
        for tif_dataset_path in [tile_info['tile_pathname'] for tile_info in stack_list]:
            index_stacker.remove(tif_dataset_path)
            logger.debug('Removed file %s', tif_dataset_path)
            index_stacker.remove((tif_dataset_path + '.aux.xml'))
            logger.debug('Removed file %s', (tif_dataset_path + '.aux.xml'))
        index_stacker.remove(vrt_stack_path)
        logger.debug('Removed file %s', vrt_stack_path)
        index_stacker.remove((vrt_stack_path + '.aux.xml'))
        logger.debug('Removed file %s', (vrt_stack_path + '.aux.xml'))
        removed_file_count += (len(stack_list) + 1)
    logger.info('Finished removing %d intermediate files in %s.', removed_file_count, index_stacker.output_dir)

dataset/ETHPy150Open GeoscienceAustralia/agdc/examples/rgb_stacker.py remove_intermediate_files/original