def naturalsize(value, binary=False, gnu=False, format='<STR_LIT>'):
if gnu:<EOL><INDENT>suffix = suffixes['<STR_LIT>']<EOL><DEDENT>elif binary:<EOL><INDENT>suffix = suffixes['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>suffix = suffixes['<STR_LIT>']<EOL><DEDENT>base = <NUM_LIT> if (gnu or binary) else <NUM_LIT:1000><EOL>bytes = float(value)<EOL>if bytes == <NUM_LIT:1> and not gnu:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>elif bytes < base and not gnu:<EOL><INDENT>return '<STR_LIT>' % bytes<EOL><DEDENT>elif bytes < base and gnu:<EOL><INDENT>return '<STR_LIT>' % bytes<EOL><DEDENT>for i, s in enumerate(suffix):<EOL><INDENT>unit = base ** (i + <NUM_LIT:2>)<EOL>if bytes < unit and not gnu:<EOL><INDENT>return (format + '<STR_LIT>') % ((base * bytes / unit), s)<EOL><DEDENT>elif bytes < unit and gnu:<EOL><INDENT>return (format + '<STR_LIT:%s>') % ((base * bytes / unit), s)<EOL><DEDENT><DEDENT>if gnu:<EOL><INDENT>return (format + '<STR_LIT:%s>') % ((base * bytes / unit), s)<EOL><DEDENT>return (format + '<STR_LIT>') % ((base * bytes / unit), s)<EOL>
Format a number of byteslike a human readable filesize (eg. 10 kB).  By
    default, decimal suffixes (kB, MB) are used.  Passing binary=true will use
    binary suffixes (KiB, MiB) are used and the base will be 2**10 instead of
    10**3.  If ``gnu`` is True, the binary argument is ignored and GNU-style
    (ls -sh style) prefixes are used (K, M) with the 2**10 definition.
    Non-gnu modes are compatible with jinja2's ``filesizeformat`` filter.