def fmt_size(size, binary=True):
if binary:<EOL><INDENT>fmt_sizes = binary_units<EOL>fmt_divider = <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>fmt_sizes = standard_units<EOL>fmt_divider = <NUM_LIT><EOL><DEDENT>for fmt in fmt_sizes[:-<NUM_LIT:1>]:<EOL><INDENT>if size < <NUM_LIT:1000>:<EOL><INDENT>return (size, fmt)<EOL><DEDENT>size /= fmt_divider<EOL><DEDENT>return size, fmt_sizes[-<NUM_LIT:1>]<EOL>
Get size and unit.

:param size: size in bytes
:type size: int
:param binary: whether use binary or standard units, defaults to True
:type binary: bool
:return: size and unit
:rtype: tuple of int and unit as str