buildTable(): small cosmetics/enhancements
authorPascal Volk <user@localhost.localdomain.org>
Mon, 08 Jun 2009 20:33:58 +0000
changeset 3 6b0d09cdfbdb
parent 2 a72ea07394cc
child 4 ae58d9881be5
buildTable(): small cosmetics/enhancements
nixspamsum
--- a/nixspamsum	Mon Jun 08 16:10:07 2009 +0000
+++ b/nixspamsum	Mon Jun 08 20:33:58 2009 +0000
@@ -93,14 +93,18 @@
     clen = len(str(max(domains.values())))
     total = sum(domains.values())
     if percent:
-        format = '%%%ds  %%%dd  %%5.2f %%%%\n' % (dlen, clen)
+        format = ' %%%ds  %%%dd  %%6.2f %%%%\n' % (-dlen, clen)
         for d, c in doms:
             dfrac = 100./total*c
             output.write(format % (d, c, dfrac))
+        output.write('%s\n' % ((clen+dlen+14)*'-'))
+        output.write(format % ('total', total, 100))
     else:
-        format = '%%%ds  %%%dd\n' % (dlen, clen)
+        format = ' %%%ds  %%%dd\n' % (-dlen, clen)
         for d in doms:
             output.write(format % d)
+        output.write('%s\n' % ((clen+dlen+4)*'-'))
+        output.write(format % ('total', total))
 
 def showResult(nixspamsum, options):
     from cStringIO import StringIO