aac_datasets.utils.download module

download_file(
url: str,
fpath: str | Path,
make_intermediate: bool = False,
verbose: int = 0,
) None[source]
hash_file(
fpath: str | Path,
hash_type: str,
chunk_size: int = 268435456,
) str[source]

Return the hash value for a file.

BASED ON https://github.com/pytorch/audio/blob/v0.13.0/torchaudio/datasets/utils.py#L110

safe_rmdir(
root: str | Path,
rm_root: bool = True,
error_on_non_empty_dir: bool = True,
followlinks: bool = False,
verbose: int = 0,
) List[str][source]

Remove all empty sub-directories.

Parameters:
  • root – Root directory path.

  • rm_root – If True, remove the root directory too. defaults to True.

  • error_on_non_empty_dir – If True, raises a RuntimeError if a subdirectory contains at least 1 file. Otherwise it will leave non-empty directories. defaults to True.

  • followlinks – Indicates whether or not symbolic links shound be followed. defaults to False.

  • verbose – Verbose level. defaults to 0.

Returns:

The list of directories paths deleted.