# Path: socceraction/data/base.py
# class MissingDataError(Exception):
#     """Exception raised when a field is missing in the input data."""
# 
# Path: socceraction/data/opta/parsers/base.py
# class OptaJSONParser(OptaParser):
#     """Extract data from an Opta JSON data stream.
# 
#     Parameters
#     ----------
#     path : str
#         Path of the data file.
#     """
# 
#     def __init__(self, path: str, **kwargs: Any) -> None:
#         with open(path, 'rt', encoding='utf-8') as fh:
#             self.root = json.load(fh)
# 
# 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 ...base import MissingDataError
from .base import OptaJSONParser, assertget
        optadocument = self._get_doc()
        attr = assertget(optadocument, '@attributes')
        matchdata = assertget(optadocument, 'MatchData')
        matches = {}
        for match in matchdata:
            matchattr = assertget(match, '@attributes')
            matchinfo = assertget(match, 'MatchInfo')
            matchinfoattr = assertget(matchinfo, '@attributes')
            game_id = int(assertget(matchattr, 'uID')[1:])
            matches[game_id] = dict(
                # Fields required by the base schema
                game_id=game_id,
                competition_id=int(assertget(attr, 'competition_id')),
                season_id=int(assertget(attr, 'season_id')),
                game_day=int(assertget(matchinfoattr, 'MatchDay')),
                game_date=datetime.strptime(assertget(matchinfo, 'Date'), '%Y-%m-%d %H:%M:%S'),
                # home_team_id=see below,
                # away_team_id=see below,
                # Optional fields
                # home_score=see below,
                # away_score=see below,
                # duration=?
                # referee=?
                # venue=?,
                # attendance=?
                # home_manager=?
                # away_manager=?
            )
            teamdata = assertget(match, 'TeamData')
            for team in teamdata:

# Path: socceraction/data/base.py
# class MissingDataError(Exception):
#     """Exception raised when a field is missing in the input data."""
# 
# Path: socceraction/data/opta/parsers/base.py
# class OptaJSONParser(OptaParser):
#     """Extract data from an Opta JSON data stream.
# 
#     Parameters
#     ----------
#     path : str
#         Path of the data file.
#     """
# 
#     def __init__(self, path: str, **kwargs: Any) -> None:
#         with open(path, 'rt', encoding='utf-8') as fh:
#             self.root = json.load(fh)
# 
# 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/f1_json.py
from datetime import datetime
from typing import Any, Dict, Tuple
from ...base import MissingDataError
from .base import OptaJSONParser, assertget

        optadocument = self._get_doc()
        attr = assertget(optadocument, '@attributes')
        matchdata = assertget(optadocument, 'MatchData')
        matches = {}
        for match in matchdata:
            matchattr = assertget(match, '@attributes')
            matchinfo = assertget(match, 'MatchInfo')
            matchinfoattr = assertget(matchinfo, '@attributes')
            game_id = int(assertget(matchattr, 'uID')[1:])
            matches[game_id] = dict(
                # Fields required by the base schema
                game_id=game_id,
                competition_id=int(assertget(attr, 'competition_id')),
                season_id=int(assertget(attr, 'season_id')),
                game_day=int(assertget(matchinfoattr, 'MatchDay')),
                game_date=datetime.strptime(assertget(matchinfo, 'Date'), '%Y-%m-%d %H:%M:%S'),
                # home_team_id=see below,
                # away_team_id=see below,
                # Optional fields
                # home_score=see below,
                # away_score=see below,
                # duration=?
                # referee=?
                # venue=?,
                # attendance=?
                # home_manager=?
                # away_manager=?
            )
            teamdata = assertget(match, 'TeamData')
            for team in teamdata:

                teamattr = assertget(team, '@attributes')