-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnemchoice.py
37 lines (31 loc) · 1.03 KB
/
nemchoice.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#! /usr/bin/python
import nominate_combo
from datetime import datetime
import time
import query
def _fixup_nominee_validity(c):
newcombos = []
for i in range(0, len(c)):
cur = c[i]
next = None
if i < len(c) - 1:
next = c[i + 1]['time']
newcombos.append([cur['combo'], cur['time'], next])
return newcombos
NEMELEX_COMBOS = _fixup_nominee_validity(
nominate_combo.find_previous_nominees())
NEMELEX_SET = set([x[0] for x in NEMELEX_COMBOS])
def current_nemelex_choice():
return NEMELEX_COMBOS and NEMELEX_COMBOS[-1]
def previous_nemelex_choices():
return NEMELEX_COMBOS and [x[0] for x in NEMELEX_COMBOS[:-1]] or []
def is_nemelex_choice(combo, when):
"""Returns true if the given combo for a game that ended at the given
datetime is a chosen combo for the Nemelex' Choice banner."""
if combo in NEMELEX_SET:
if isinstance(when, str) or isinstance(when, unicode):
when = query.time_from_str(when)
for c in NEMELEX_COMBOS:
if c[0] == combo and when >= c[1]:
return True
return False