idmtools.utils.file module¶
utilities for files.
Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.
- idmtools.utils.file.scan_directory(basedir: str, recursive: bool = True, ignore_directories: Optional[List[str]] = None) Iterable[DirEntry] ¶
Scan a directory recursively or not.
- Parameters:
basedir – The root directory to start from.
recursive – True to search the sub-folders recursively; False to stay in the root directory.
ignore_directories – Ignore directories
- Returns:
An iterator yielding all the files found.
- idmtools.utils.file.file_contents_to_generator(filename, chunk_size=128) Generator[bytearray, None, None] ¶
Create a generator from file contents in chunks(useful for streaming binary data and piping).
- Parameters:
filename –
chunk_size –
- Returns:
Generator that return bytes in chunks of size chunk_size