Permalink
Browse files

postscreen_stats: reformat list of blocked countries

The hard coded formatting of blocked countries count is 
now dynamic based off of the maximum value.

patch from Dan Larsson - dl[at]tyfon.net
  • Loading branch information...
1 parent 3eedb7a commit b85d19dc3e64dfcb2e29bec7990e2dd3eba7f55e Julien Vehent committed May 26, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 postscreen_stats.py
View
@@ -485,11 +485,14 @@ def action_filter(self,filter):
from operator import itemgetter
sorted_countries = blocked_countries.items()
sorted_countries.sort(key = itemgetter(1), reverse=True)
+ count_format = ""
for i in range(20):
if i < len(sorted_countries):
country,clients = sorted_countries[i]
- cpercent = "(%5.2f%%)" % float(Decimal(clients)/total_blocked*100)
- print "%4d" % clients, cpercent, country
+ if count_format in "":
+ count_format = "%" + str(len(str(clients))) + "d"
+ client_percent = "(%5.2f%%)" % float(Decimal(clients)/total_blocked*100)
+ print count_format % clients, client_percent, country
# generate the HTML for the google map and store it in a file
if MAPDEST not in "" and GEOLOC > 1:

0 comments on commit b85d19d

Please sign in to comment.