Skip to content

Commit

Permalink
gfptar: prevent the progress message from being shortened
Browse files Browse the repository at this point in the history
  • Loading branch information
takuya-isbs committed Oct 1, 2024
1 parent 3f7d3a9 commit 75872ea
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gftool/gfptar/gfptar
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def format_seconds(seconds, minhour=False):
return f"{seconds:.0f}s({minutes:.1f}m)"
else:
hours = seconds / 3600
return f"{seconds:.0f}s({hours:.1f}h)"
# Prevent the string from being shortened
# ex. '1.1h' -> ' 1.1h'
return f"{seconds:.0f}s({hours:4.1f}h)"


def humanize_number(num, binary_prefix=False):
Expand All @@ -84,13 +86,18 @@ def humanize_number(num, binary_prefix=False):
n /= base
scale += 1
if n < 10:
# ex. '1.23'
d = n.quantize(Decimal('0.00'), rounding=ROUND_DOWN)
elif n < 100:
# ex. '12.3'
d = n.quantize(Decimal('0.0'), rounding=ROUND_DOWN)
elif n < 1000:
d = n.quantize(Decimal('0'), rounding=ROUND_DOWN)
# Prevent the string from being shortened
# ex. ' 123'
d = f" {d}"
else:
# ex. '1234'
d = n.quantize(Decimal('0'), rounding=ROUND_DOWN)
return f"{d}{units[scale]}"

Expand Down

0 comments on commit 75872ea

Please sign in to comment.