From 81a2bcc42f1eed4f4e748672fc7dcb631fae0223 Mon Sep 17 00:00:00 2001 From: Pieter Robberechts Date: Fri, 29 Dec 2023 18:17:10 +0100 Subject: [PATCH] fix(statsbomb): set throw-in body part to "other" --- socceraction/spadl/statsbomb.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/socceraction/spadl/statsbomb.py b/socceraction/spadl/statsbomb.py index a747a3d5..b690149a 100644 --- a/socceraction/spadl/statsbomb.py +++ b/socceraction/spadl/statsbomb.py @@ -244,6 +244,7 @@ def _parse_event_as_non_action(_extra: dict[str, Any]) -> tuple[str, str, str]: def _parse_pass_event(extra: dict[str, Any]) -> tuple[str, str, str]: # noqa: C901 a = 'pass' # default + b = 'foot' # default p = extra.get('pass', {}) ptype = p.get('type', {}).get('name') height = p.get('height', {}).get('name') @@ -262,6 +263,7 @@ def _parse_pass_event(extra: dict[str, Any]) -> tuple[str, str, str]: # noqa: C a = 'goalkick' elif ptype == 'Throw-in': a = 'throw_in' + b = 'other' elif cross: a = 'cross' else: @@ -280,18 +282,17 @@ def _parse_pass_event(extra: dict[str, Any]) -> tuple[str, str, str]: # noqa: C r = 'success' bp = extra.get('pass', {}).get('body_part', {}).get('name') - if bp is None: - b = 'foot' - elif 'Head' in bp: - b = 'head' - elif bp == 'Left Foot': - b = 'foot_left' - elif bp == 'Right Foot': - b = 'foot_right' - elif 'Foot' in bp or bp == 'Drop Kick': - b = 'foot' - else: - b = 'other' + if bp is not None: + if 'Head' in bp: + b = 'head' + elif bp == 'Left Foot': + b = 'foot_left' + elif bp == 'Right Foot': + b = 'foot_right' + elif 'Foot' in bp or bp == 'Drop Kick': + b = 'foot' + else: + b = 'other' return a, r, b @@ -453,7 +454,7 @@ def _parse_clearance_event(extra: dict[str, Any]) -> tuple[str, str, str]: r = 'success' bp = extra.get('clearance', {}).get('body_part', {}).get('name') if bp is None: - b = 'other' + b = 'foot' elif 'Head' in bp: b = 'head' elif bp == 'Left Foot':