U su]aa@sdZddddZd ddZd S) z$Bits and bytes related humanization.)ZkBZMBZGBZTBZPBZEBZZBZYB)ZKiBZMiBZGiBZTiBZPiBZEiBZZiBZYiBZKMGTPEZY)decimalbinarygnuF%.1fc Cs$|rtd}n|rtd}ntd}|s,|r0dnd}t|}t|}|dkrX|sXd|S||krl|sld|S||kr|rd |St|D]d\}} ||d } || kr|s|d ||| | fS|| kr|r|d ||| | fSq|r |d ||| | fS|d ||| | fS) aFormat a number of bytes like a human readable filesize (e.g. 10 kB). By default, decimal suffixes (kB, MB) are used. Non-GNU modes are compatible with jinja2's `filesizeformat` filter. Examples: ```pycon >>> naturalsize(3000000) '3.0 MB' >>> naturalsize(300, False, True) '300B' >>> naturalsize(3000, False, True) '2.9K' >>> naturalsize(3000, False, True, "%.3f") '2.930K' >>> naturalsize(3000, True) '2.9 KiB' ``` Args: value (int, float, str): Integer to convert. binary (bool): If `True`, uses binary suffixes (KiB, MiB) with base 210 instead of 103. gnu (bool): If `True`, the binary argument is ignored and GNU-style (`ls -sh` style) prefixes are used (K, M) with the 2**10 definition. format (str): Custom formatter. Returns: str: Human readable representation of a filesize. rrriiz%d Bytez%d Bytesz%dBz %sz%s)suffixesfloatabs enumerate) valuerrformatsuffixbasebytesZ abs_bytesisZunitrB/opt/alt/python38/lib/python3.8/site-packages/humanize/filesize.py naturalsize s.         rN)FFr)__doc__rrrrrrs