Skip to content

Commit

Permalink
removed try except
Browse files Browse the repository at this point in the history
  • Loading branch information
Joris Bekkers committed May 28, 2024
1 parent d4162f7 commit 615e4e9
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions kloppy/infra/serializers/event/opta/deserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,11 @@ def deserialize(self, inputs: OptaInputs) -> EventDataset:
matchdata_path = objectify.ObjectPath(
"SoccerFeed.SoccerDocument.MatchData"
)
match_result_path = objectify.ObjectPath(
"SoccerFeed.SoccerDocument.MatchData.MatchInfo.Result"

result_elements = f7_root.xpath(
"/SoccerFeed/SoccerDocument/MatchData/MatchInfo/Result"
)

team_elms = list(
matchdata_path.find(f7_root).iterchildren("TeamData")
)
Expand All @@ -726,13 +728,12 @@ def deserialize(self, inputs: OptaInputs) -> EventDataset:
)
score = Score(home=home_score, away=away_score)
teams = [home_team, away_team]
try:
match_result_type = list(match_result_path.find(f7_root))[
0
].attrib["Type"]
except AttributeError:

if result_elements and "Type" in result_elements[0].attrib:
match_result_type = result_elements[0].attrib["Type"]
else:
match_result_type = None

periods = _create_periods(match_result_type)

if len(home_team.players) == 0 or len(away_team.players) == 0:
Expand Down

0 comments on commit 615e4e9

Please sign in to comment.