105 output.write(format % d) |
105 output.write(format % d) |
106 output.write('%s\n' % ((clen+dlen+4)*'-')) |
106 output.write('%s\n' % ((clen+dlen+4)*'-')) |
107 output.write(format % ('total', total)) |
107 output.write(format % ('total', total)) |
108 |
108 |
109 def showResult(nixspamsum, options): |
109 def showResult(nixspamsum, options): |
110 from cStringIO import StringIO |
|
111 output = StringIO() |
|
112 if options.countByDom: |
110 if options.countByDom: |
113 nixspamsum.countByDom() |
111 nixspamsum.countByDom() |
114 domains = nixspamsum.getDomains() |
112 domains = nixspamsum.getDomains() |
115 else: |
113 else: |
116 domains = nixspamsum.getMXs() |
114 domains = nixspamsum.getMXs() |
|
115 if not len(domains): |
|
116 print "No Nix Spam RBL rejects found" |
|
117 return |
|
118 |
|
119 from cStringIO import StringIO |
|
120 output = StringIO() |
117 # build the table |
121 # build the table |
118 if options.oFormat == 'table': |
122 if options.oFormat == 'table': |
119 buildTable(output, domains, options.percent, options.order) |
123 buildTable(output, domains, options.percent, options.order) |
120 # generate comma separated values |
124 # generate comma separated values |
121 elif options.oFormat == 'csv': |
125 elif options.oFormat == 'csv': |
122 for d in domains.items(): |
126 order = domains.keys() |
123 output.write("'%s',%d\n" % d) |
127 order.sort() |
|
128 for d in order: |
|
129 output.write("'%s',%d\n" % (d, domains[d])) |
124 # should never be reached |
130 # should never be reached |
125 else: |
131 else: |
126 print "Oops, error in function showResult() happend" |
132 print "Oops, error in function showResult() happend" |
127 # show the result |
133 # show the result |
128 print output.getvalue() |
134 print output.getvalue() |