-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplayerinput.py
45 lines (36 loc) · 1.04 KB
/
playerinput.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
41
42
43
44
45
#!/usr/bin/python
import csv
from abc import ABCMeta, abstractmethod
from model import Player
class PlayerReader:
__metaclass__ = ABCMeta
@abstractmethod
def getPlayers(self):
pass
@abstractmethod
def getExclusions(self):
pass
class CSVPlayerReader(PlayerReader):
def __init__(self, playerFile, exclusionFile):
self.playerFile = playerFile
self.exclusionFile = exclusionFile
players = []
exclusions = []
# First name, Last name, Email
for row in csv.reader(self.playerFile):
assert len(row) == 3
players.append(Player(*row))
# Firstname lastname, Firstname lastname
for row in csv.reader(self.exclusionFile):
assert len(row) == 2
g, r = row
# Verify players
gifterExclusion = (x for x in players if x.getname() == g).next()
receiverExclusion = (x for x in players if x.getname() == r).next()
exclusions.append((gifterExclusion, receiverExclusion))
self.players = players
self.exclusions = exclusions
def getPlayers(self):
return self.players
def getExclusions(self):
return self.exclusions