Write data to a given ``filepath`` with 'wb' mode. Note: ``write`` will create a directory if the directory of ``filepath`` does not exist. Args: obj (bytes): Data to be written. filepath (str or Path): Path to write data.
(obj: bytes, filepath: Union[str, Path])
| 581 | |
| 582 | |
| 583 | def ensure_write(obj: bytes, filepath: Union[str, Path]) -> None: |
| 584 | """Write data to a given ``filepath`` with 'wb' mode. |
| 585 | |
| 586 | Note: |
| 587 | ``write`` will create a directory if the directory of ``filepath`` |
| 588 | does not exist. |
| 589 | |
| 590 | Args: |
| 591 | obj (bytes): Data to be written. |
| 592 | filepath (str or Path): Path to write data. |
| 593 | """ |
| 594 | dirname = os.path.dirname(filepath) |
| 595 | if dirname and not os.path.exists(dirname): |
| 596 | os.makedirs(dirname, exist_ok=True) |
| 597 | |
| 598 | with open(filepath, 'wb') as f: |
| 599 | f.write(obj) |
| 600 | |
| 601 | |
| 602 | def _save_index(index, file_path, file_list=None, with_template=False): |
no test coverage detected
searching dependent graphs…