Skip to content

Commit 69177e0

Browse files
committed
add Race class with clean_office private method
1 parent 36ae3b9 commit 69177e0

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

elex4/lib/models.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11

2+
class Race(object):
3+
4+
def __init__(self, date, raw_office):
5+
self.date = date
6+
self.office, self.district = self.__clean_office(raw_office)
7+
8+
# Private methods
9+
def __clean_office(self, office):
10+
if 'Rep' in office:
11+
office_clean = 'U.S. House of Representatives'
12+
district = int(office.split('-')[-1])
13+
else:
14+
office_clean = office.strip()
15+
district = ''
16+
return office_clean, district
17+
18+
219
class Candidate(object):
320

421
def __init__(self, raw_name, party):

0 commit comments

Comments
 (0)