X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=apt_p2p%2Futil.py;h=ec0287cec4bc9790ad348a232d769644844b7445;hb=19dab12a49b05e17b3fc9e6fc246c31f157b4f48;hp=3d1a50eafb4e813eb1e3a360f94dbd52cc546ee9;hpb=d563aab35fc0fd1fab59e0f6d594fbb05735cf21;p=quix0rs-apt-p2p.git diff --git a/apt_p2p/util.py b/apt_p2p/util.py index 3d1a50e..ec0287c 100644 --- a/apt_p2p/util.py +++ b/apt_p2p/util.py @@ -160,11 +160,15 @@ def byte_format(s): @param s: the number of bytes @rtype: C{string} @return: the formatted size with appropriate units - """ - - if (s < 1024): - r = str(s) + 'B' + if (s < 1): + r = str(int(s*1000.0)/1000.0) + 'B' + elif (s < 10): + r = str(int(s*100.0)/100.0) + 'B' + elif (s < 102): + r = str(int(s*10.0)/10.0) + 'B' + elif (s < 1024): + r = str(int(s)) + 'B' elif (s < 10485): r = str(int((s/1024.0)*100.0)/100.0) + 'KiB' elif (s < 104857):