From da7f9d5a337bf2596a0fbda2a9b668b08c41cee6 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 22 Sep 2006 20:20:35 +0000 Subject: r8911@Kushana: nickm | 2006-09-22 12:24:52 -0400 Make exitlist only output each result line once. svn:r8466 --- contrib/exitlist | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'contrib/exitlist') diff --git a/contrib/exitlist b/contrib/exitlist index 2b7785fb75..de26dab89c 100755 --- a/contrib/exitlist +++ b/contrib/exitlist @@ -200,6 +200,13 @@ class Server: self.ip = ip self.policy = policy +def uniq_sort(lst): + d = {} + for item in lst: d[item] = 1 + lst = d.keys() + lst.sort() + return lst + def run(): servers = [] policy = [] @@ -237,12 +244,13 @@ def run(): else: printlist = accepters + ents = [] if VERBOSE: - for s in printlist: - print "%s\t%s"%(s.ip,s.name) + ents = uniq_sort([ "%s\t%s"%(s.ip,s.name) for s in printlist ]) else: - for s in printlist: - print s.ip + ents = uniq_sort([ s.ip for s in printlist ]) + for e in ents: + print e def _test(): import doctest, exitparse -- cgit v1.2.3-54-g00ecf