Skip to content

optional_temp_path

fastagency.helpers.optional_temp_path #

optional_temp_path(
    path: Optional[str] = None,
) -> Iterator[Path]
Source code in fastagency/helpers.py
@contextmanager
def optional_temp_path(path: Optional[str] = None) -> Iterator[Path]:
    if path is None:
        with tempfile.TemporaryDirectory() as temp_dir:
            yield Path(temp_dir)
    else:
        yield Path(path)