summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-09-22 20:59:13 +0000
committerLennart Poettering <lennart@poettering.net>2006-09-22 20:59:13 +0000
commitc8f165b46c333b995f05d6568ccefb7061fdb5d2 (patch)
treee1c759530dcf80b52d632ddce035a5ff612cadba
parent6a9fcd2bc707969699db05c0be61865124661973 (diff)
create new file fringutil.py and move the size pretty printing function into it
git-svn-id: file:///home/lennart/svn/public/fring/trunk@13 d0d2c35f-0a1e-0410-abeb-dabff30a67ee
-rw-r--r--src/fringlib/fringutil.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/fringlib/fringutil.py b/src/fringlib/fringutil.py
new file mode 100644
index 0000000..e174d66
--- /dev/null
+++ b/src/fringlib/fringutil.py
@@ -0,0 +1,12 @@
+
+def pretty_size(size):
+ if size >= 1024*1024*1024:
+ return "%.1f GiB" % round(size/1024/1024/1024.0)
+ elif size >= 1024*1024:
+ return "%.1f MiB" % round(size/1024/1024.0)
+ elif size >= 1024:
+ return "%.1f KiB" % round(size/1024.0)
+ else:
+ return "%u B" % size
+
+