# HG changeset patch
# User Pascal Volk <user@localhost.localdomain.org>
# Date 1246655523 0
# Node ID ae58d9881be5fae1c3f198f901bb855ed0d5097e
# Parent  6b0d09cdfbdb9e8a05602c493d8392188dde0b26
showResult(): count matches; break if no matches were found
	      sort by domain name if the output format is CSV

diff -r 6b0d09cdfbdb -r ae58d9881be5 nixspamsum
--- a/nixspamsum	Mon Jun 08 20:33:58 2009 +0000
+++ b/nixspamsum	Fri Jul 03 21:12:03 2009 +0000
@@ -3,8 +3,8 @@
 # Copyright 2009 Pascal Volk
 
 __author__ = 'Pascal Volk'
-__version__ = '0.1.1'
-__date__ = '2009-06-08'
+__version__ = '0.1.2'
+__date__ = '2009-07-03'
 
 import os
 import re
@@ -107,20 +107,26 @@
         output.write(format % ('total', total))
 
 def showResult(nixspamsum, options):
-    from cStringIO import StringIO
-    output = StringIO()
     if options.countByDom:
         nixspamsum.countByDom()
         domains = nixspamsum.getDomains()
     else:
         domains = nixspamsum.getMXs()
+    if not len(domains):
+        print "No Nix Spam RBL rejects found"
+        return
+
+    from cStringIO import StringIO
+    output = StringIO()
     # build the table
     if options.oFormat == 'table':
         buildTable(output, domains, options.percent, options.order)
     # generate comma separated values
     elif options.oFormat == 'csv':
-        for d in domains.items():
-            output.write("'%s',%d\n" % d)
+        order = domains.keys()
+        order.sort()
+        for d in order:
+            output.write("'%s',%d\n" % (d, domains[d]))
     # should never be reached
     else:
         print "Oops, error in function showResult() happend"