Make the downloader statistics work.
[quix0rs-apt-p2p.git] / apt_p2p_Khashmir / util.py
index 39b4ce00ebd7e36c40f45baaf6bb1976bf3abafc..55bd45ac1f102812706f1177b3838d153d2ec129 100644 (file)
@@ -69,11 +69,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):