utils

The junk drawer my dogs

mio.utils.exact_iter(f: Callable[[], T], sentinel: T) Generator[T, None, None]

A version of iter() that compares with is rather than == because truth value of numpy arrays is ambiguous.

Parameters:
  • f – Function to call repeatedly

  • sentinel – Sentinel value to stop iteration when f() returns this (compared with is)

Yields:

Values from f() until sentinel is encountered

mio.utils.hash_file(path: Path | str) str

Return the sha256 hash of a file

Parameters:
  • path (pathlib.Path) – File to hash

  • hash (str) – Hash algorithm to use

Returns:

Hash of file

Return type:

str

References

https://stackoverflow.com/a/44873382

mio.utils.hash_video(path: Path | str, method: str = 'blake2s') str

Create a hash of a video by digesting the byte string each of its decoded frames.

Intended to remove variability in video encodings across platforms.

Parameters:
Returns:

str