Skip to content

Commit

Permalink
filesize: more cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
bbolli committed Aug 19, 2023
1 parent 4551ca0 commit a0bb67a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/humanize/filesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,11 @@ def naturalsize(
if abs_bytes == 1 and not gnu:
return "%d Byte" % bytes_

if abs_bytes < base and not gnu:
return "%d Bytes" % bytes_

if abs_bytes < base and gnu:
return "%dB" % bytes_

for i, s in enumerate(suffix):
unit = base ** (i + 2)
if abs_bytes < base:
return ("%dB" if gnu else "%d Bytes") % bytes_

for i, s in enumerate(suffix, 2):
unit = base**i
if abs_bytes < unit:
break

Expand Down

0 comments on commit a0bb67a

Please sign in to comment.