here.platform.utils.file module

here.platform.utils.file module

This module contains helper functions for various file operations.

here.platform.utils.file.checksum(path_or_data: str | Path | bytes, hash_algo: str, chunk_num_blocks: int = 128) str

Calculate checksum for data in a file based on input hashing algorithm.

Parameters:

  • path_or_data – A string representing path of the file.

  • hash_algo – A string representing name of hashing algorithm.

  • chunk_num_blocks – An int representing block size.

Returns:
A checksum string.

Raises:
ValueError – If file does not exist or hash_algo is not valid.

here.platform.utils.file.get_crc(path_or_data: str | Path | bytes)

Calculate crc for data.

here.platform.utils.file.get_readable_bytes(size: int) str

Get a human-readable representation of the given number of bytes.

Parameters:
size – the number of bytes

Returns:
the size scaled to KB, MB, GB or TB with units