blob: 5ac9ba990d373ffc8b6e426193ea0df4f0ff0f7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/usr/bin/env python3
import json
from os import environ
import sys
import os
import poll
f = 'suggestions.json'
title=" ".join(sys.argv[1:])
db = poll.load_db(f)
limit = int(sys.argv[1]) if len(sys.argv) > 1 else 1
num = 1
# stolen from http://stackoverflow.com/questions/9647202/ordinal-numbers-replacement
suffixes = ["th", "st", "nd", "rd", ] + ["th"] * 16
for entry in poll.sort_by_votes(db):
suffixed_num = str(num) + suffixes[num % 100]
print("%s: '%s' (%d votes)" %
(suffixed_num,entry['title'],sum(entry['votes'].values())))
num = num + 1
if num > limit:
sys.exit(0)
|