Replace deprecated locale.format()

locale.format_string() was introduced in Python 2.5.
This commit is contained in:
Chris Mayo 2019-04-21 19:26:24 +01:00
parent 5d26d2d93e
commit ce1dd55d7a

View file

@ -190,18 +190,18 @@ def strsize (b, grouping=True):
if b < 0:
raise ValueError("Invalid negative byte number")
if b < 1024:
return u"%sB" % locale.format("%d", b, grouping)
return u"%sB" % locale.format_string("%d", b, grouping)
if b < 1024 * 10:
return u"%sKB" % locale.format("%d", (b // 1024), grouping)
return u"%sKB" % locale.format_string("%d", (b // 1024), grouping)
if b < 1024 * 1024:
return u"%sKB" % locale.format("%.2f", (float(b) / 1024), grouping)
return u"%sKB" % locale.format_string("%.2f", (float(b) / 1024), grouping)
if b < 1024 * 1024 * 10:
return u"%sMB" % locale.format("%.2f", (float(b) / (1024*1024)), grouping)
return u"%sMB" % locale.format_string("%.2f", (float(b) / (1024*1024)), grouping)
if b < 1024 * 1024 * 1024:
return u"%sMB" % locale.format("%.1f", (float(b) / (1024*1024)), grouping)
return u"%sMB" % locale.format_string("%.1f", (float(b) / (1024*1024)), grouping)
if b < 1024 * 1024 * 1024 * 10:
return u"%sGB" % locale.format("%.2f", (float(b) / (1024*1024*1024)), grouping)
return u"%sGB" % locale.format("%.1f", (float(b) / (1024*1024*1024)), grouping)
return u"%sGB" % locale.format_string("%.2f", (float(b) / (1024*1024*1024)), grouping)
return u"%sGB" % locale.format_string("%.1f", (float(b) / (1024*1024*1024)), grouping)
def strtime (t, func=time.localtime):