Skip to content

Commit

Permalink
Merge pull request #528 from roclark/fix-fb-position
Browse files Browse the repository at this point in the history
Fix issue pulling football league positions
  • Loading branch information
roclark authored Nov 13, 2020
2 parents 9b6039f + 20d3ec0 commit 4c3c1e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions sportsreference/fb/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,15 @@ def _records(self, record_line):
records = record_line.lower().replace('record: ', '')
records_split = records.split(',')
if len(records_split) != 3:
return None, None, None
return None, None, None, None
record, points, position = records_split
points = re.sub(' point.*', '', points).strip()
position = re.sub(r'\(.*\)', '', position).strip()
league = re.sub('.* in ', '', position).title()
position = re.findall(r'\d+', position)[0]
try:
position = re.findall(r'\d+', position)[0]
except IndexError:
position = None
return record, points, position, league

def _goals(self, goals_line):
Expand Down
9 changes: 8 additions & 1 deletion tests/unit/test_fb_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,14 @@ def test_records_missing_result(self):

output = self.team._records(html)

assert output == (None, None, None)
assert output == (None, None, None, None)

def test_records_missing_position(self):
html = 'Record: 5-0-0, 15 points (3.0 per game), Premier League'

output = self.team._records(html)

assert output == ('5-0-0', '15', None, 'Premier League')

def test_goals_missing(self):
html = 'Goals: 20 (2.5 per game), Goals Against: 11 (1.38 per game)'
Expand Down

0 comments on commit 4c3c1e7

Please sign in to comment.