Utilities

bhopengraph.utils.filesize_string(size)[source]

Convert a file size from bytes to a more readable format using the largest appropriate unit.

This function takes an integer representing a file size in bytes and converts it to a human-readable string using the largest appropriate unit from bytes (B) to petabytes (PB). The result is rounded to two decimal places.

Parameters:

size (int) – The file size in bytes.

Returns:

A string representing the file size in a more readable format, including the appropriate unit.

Return type:

str