# Path: socceraction/data/opta/parsers/base.py
# class OptaXMLParser(OptaParser):
#     """Extract data from an Opta XML data stream.
# 
#     Parameters
#     ----------
#     path : str
#         Path of the data file.
#     """
# 
#     def __init__(self, path: str, **kwargs: Any) -> None:
#         with open(path, 'rb') as fh:
#             self.root = objectify.fromstring(fh.read())
# 
# def assertget(dictionary: Dict[str, Any], key: str) -> Any:
#     """Return the value of the item with the specified key.
# 
#     In contrast to the default `get` method, this version will raise an
#     assertion error if the given key is not present in the dict.
# 
#     Parameters
#     ----------
#     dictionary : dict
#         A Python dictionary.
#     key : str
#         A key in the dictionary.
# 
#     Returns
#     -------
#     Any
#         Returns the value for the specified key if the key is in the dictionary.
# 
#     Raises
#     ------
#     AssertionError
#         If the given key could not be found in the dictionary.
#     """
#     value = dictionary.get(key)
#     assert value is not None, 'KeyError: ' + key + ' not found in ' + str(dictionary)
#     return value


from datetime import datetime
from typing import Any, Dict, Tuple
from lxml import objectify
from .base import OptaXMLParser, assertget
        competition_id = int(competition.attrib['uID'][1:])
        competition_stats = self._get_stats(competition)
        match_info = optadocument.MatchData.MatchInfo
        game_id = int(optadocument.attrib['uID'][1:])
        stats = self._get_stats(optadocument.MatchData)
        team_data_elms = {
            t.attrib['Side']: t for t in optadocument.MatchData.iterchildren('TeamData')
        }
        team_officials = {}
        for t in optadocument.iterchildren('Team'):
            side = (
                "Home"
                if int(team_data_elms["Home"].attrib["TeamRef"][1:]) == int(t.attrib['uID'][1:])
                else "Away"
            )
            for m in t.iterchildren('TeamOfficial'):
                if m.attrib["Type"] == "Manager":
                    team_officials[side] = m

        game_dict = dict(
            # Fields required by the base schema
            game_id=game_id,
            season_id=int(assertget(competition_stats, 'season_id')),
            competition_id=competition_id,
            game_day=int(competition_stats['matchday'])
            if "matchday" in competition_stats
            else None,
            game_date=datetime.strptime(match_info.Date.text, '%Y%m%dT%H%M%S%z').replace(
                tzinfo=None
            ),

# Path: socceraction/data/opta/parsers/base.py
# class OptaXMLParser(OptaParser):
#     """Extract data from an Opta XML data stream.
# 
#     Parameters
#     ----------
#     path : str
#         Path of the data file.
#     """
# 
#     def __init__(self, path: str, **kwargs: Any) -> None:
#         with open(path, 'rb') as fh:
#             self.root = objectify.fromstring(fh.read())
# 
# def assertget(dictionary: Dict[str, Any], key: str) -> Any:
#     """Return the value of the item with the specified key.
# 
#     In contrast to the default `get` method, this version will raise an
#     assertion error if the given key is not present in the dict.
# 
#     Parameters
#     ----------
#     dictionary : dict
#         A Python dictionary.
#     key : str
#         A key in the dictionary.
# 
#     Returns
#     -------
#     Any
#         Returns the value for the specified key if the key is in the dictionary.
# 
#     Raises
#     ------
#     AssertionError
#         If the given key could not be found in the dictionary.
#     """
#     value = dictionary.get(key)
#     assert value is not None, 'KeyError: ' + key + ' not found in ' + str(dictionary)
#     return value


# Path: socceraction/data/opta/parsers/f7_xml.py
from datetime import datetime
from typing import Any, Dict, Tuple
from lxml import objectify
from .base import OptaXMLParser, assertget

        competition_id = int(competition.attrib['uID'][1:])
        competition_stats = self._get_stats(competition)
        match_info = optadocument.MatchData.MatchInfo
        game_id = int(optadocument.attrib['uID'][1:])
        stats = self._get_stats(optadocument.MatchData)
        team_data_elms = {
            t.attrib['Side']: t for t in optadocument.MatchData.iterchildren('TeamData')
        }
        team_officials = {}
        for t in optadocument.iterchildren('Team'):
            side = (
                "Home"
                if int(team_data_elms["Home"].attrib["TeamRef"][1:]) == int(t.attrib['uID'][1:])
                else "Away"
            )
            for m in t.iterchildren('TeamOfficial'):
                if m.attrib["Type"] == "Manager":
                    team_officials[side] = m

        game_dict = dict(
            # Fields required by the base schema
            game_id=game_id,
            season_id=int(assertget(competition_stats, 'season_id')),
            competition_id=competition_id,
            game_day=int(competition_stats['matchday'])
            if "matchday" in competition_stats
            else None,
            game_date=datetime.strptime(match_info.Date.text, '%Y%m%dT%H%M%S%z').replace(
                tzinfo=None
            ),

            home_team_id=int(assertget(assertget(team_data_elms, "Home").attrib, "TeamRef")[1:]),