[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r16504: {projects} Accept optional argument: shorter, reject, accept. defaults (projects/dir-stats/trunk)



Author: weasel
Date: 2008-08-11 18:36:25 -0400 (Mon, 11 Aug 2008)
New Revision: 16504

Modified:
   projects/dir-stats/trunk/exit-summary
Log:
Accept optional argument: shorter, reject, accept.  defaults to printing both

Modified: projects/dir-stats/trunk/exit-summary
===================================================================
--- projects/dir-stats/trunk/exit-summary	2008-08-11 22:30:03 UTC (rev 16503)
+++ projects/dir-stats/trunk/exit-summary	2008-08-11 22:36:25 UTC (rev 16504)
@@ -70,9 +70,24 @@
 		end
 		compress_list(@rejected).collect { |i| (i.from != i.to) ? "#{i.from}-#{i.to}" : i.to.to_s }.join(",")
 	end
-	def print
-		puts "accept " +get_accept
-		puts "reject " +get_reject
+	def print(kind)
+		a=get_accept
+		r=get_reject
+		case kind
+			when "accept"
+				puts "accept " +a
+			when "reject"
+				puts "reject " +r
+			when "shorter"
+				if r.length < a.length
+					puts "reject "+r
+				else
+					puts "accept "+a
+				end
+			else
+				puts "accept " +a
+				puts "reject " +r
+		end
 	end
 	def split(port)
 		port="1-#{MAX_TCP}" if port == "*"
@@ -150,7 +165,7 @@
 	next unless line =~ /^(reject|accept) /
 	p.add line
 end
-p.print
+p.print(ARGV.first)