ensure_filelike
#
- class gufe.utils.ensure_filelike(fn, mode=None, force_close=False)#
Context manager to convert pathlike or filelike to filelike.
This makes it so that methods can allow a range of user inputs.
- Parameters:
fn (PathLike or FileLike) – The user input to normalize.
mode (str or None) – The mode, if
fn
is pathlike. Iffn
is filelike, a warning will be emitted and the mode will be ignored.force_close (bool, default False) – Whether to forcibly close the stream on exit. For pathlike inputs, the stream will always be closed. Filelike inputs will close if this parameter is True.