-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrosters.py
executable file
·40 lines (30 loc) · 1.02 KB
/
rosters.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
38
39
40
#!/usr/bin/env python
import getpass
import gspread
from normalize import *
KEYWORDS = {"HITTERS", "RESERVES", "PITCHERS"}
OTHERS = ['Carter', 'Dugan', 'Duke', 'Kolman', 'Nelson', 'Owsen', 'Prowell', 'Stack', 'Valla']
ME = ['Whitaker']
ALL = OTHERS + ME
def fetch_rosters(username='[email protected]', password=None):
if not password:
password = getpass.getpass()
gc = gspread.login(username, password)
sh = gc.open_by_key('0AlGIrGDLUd5OdHpDSm55Y1Utd0hrQUJDN1NRRVVUTlE')
sheets = sh.worksheets()
rosters = {} # map from player name to set of players
for player in ALL:
ws = sh.worksheet(player)
roster = set()
rows = ws.get_all_values()
for row in rows[4:]:
if 'RELEASED' in row:
break
name = row[1]
if name not in KEYWORDS:
roster.add(normalize(name))
rosters[player] = roster
return rosters
if __name__ == '__main__':
rosters = fetch_rosters()
print rosters['Whitaker']