skbio.util.remove_files

skbio.util.remove_files(list_of_filepaths, error_on_missing=True)[source]

Remove list of filepaths, optionally raising an error if any are missing

Parameters:

list_of_filepaths : list of strings

list with filepaths to remove

error_on_missing : bool, optional

whether or not the function should raise an OSError if a file is not found

Raises:

OSError

If a filepath in the list does not exist

Examples

>>> from tempfile import NamedTemporaryFile
>>> from os.path import exists
>>> from skbio.util import remove_files
>>> h = NamedTemporaryFile(delete=False)
>>> exists(h.name) # it exists
True
>>> remove_files([h.name])
>>> exists(h.name) # and now it's gone
False