Skip to content

Commit

Permalink
postscreen_stats: reformat list of blocked countries
Browse files Browse the repository at this point in the history
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
Julien Vehent committed May 26, 2012
1 parent 3eedb7a commit b85d19d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions postscreen_stats.py
Expand Up @@ -485,11 +485,14 @@ def action_filter(self,filter):
from operator import itemgetter from operator import itemgetter
sorted_countries = blocked_countries.items() sorted_countries = blocked_countries.items()
sorted_countries.sort(key = itemgetter(1), reverse=True) sorted_countries.sort(key = itemgetter(1), reverse=True)
count_format = ""
for i in range(20): for i in range(20):
if i < len(sorted_countries): if i < len(sorted_countries):
country,clients = sorted_countries[i] country,clients = sorted_countries[i]
cpercent = "(%5.2f%%)" % float(Decimal(clients)/total_blocked*100) if count_format in "":
print "%4d" % clients, cpercent, country 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 # generate the HTML for the google map and store it in a file
if MAPDEST not in "" and GEOLOC > 1: if MAPDEST not in "" and GEOLOC > 1:
Expand Down

0 comments on commit b85d19d

Please sign in to comment.