# 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 _get_end_x(qualifiers: Dict[int, Any]) -> Optional[float]:
#     try:
#         # pass
#         if 140 in qualifiers:
#             return float(qualifiers[140])
#         # blocked shot
#         if 146 in qualifiers:
#             return float(qualifiers[146])
#         # passed the goal line
#         if 102 in qualifiers:
#             return float(100)
#         return None
#     except ValueError:
#         return None
# 
# def _get_end_y(qualifiers: Dict[int, Any]) -> Optional[float]:
#     try:
#         # pass
#         if 141 in qualifiers:
#             return float(qualifiers[141])
#         # blocked shot
#         if 147 in qualifiers:
#             return float(qualifiers[147])
#         # passed the goal line
#         if 102 in qualifiers:
#             return float(qualifiers[102])
#         return None
#     except ValueError:
#         return None
# 
# 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, List, Optional, Tuple
from ...base import MissingDataError
from .base import OptaJSONParser, _get_end_x, _get_end_y, assertget
import pandas as pd
    """

    _position_map = {
        1: "Goalkeeper",
        2: "Defender",
        3: "Midfielder",
        4: "Forward",
        5: "Substitute",
    }

    def _get_match_info(self) -> Dict[str, Any]:
        if "matchInfo" in self.root:
            return self.root["matchInfo"]
        raise MissingDataError

    def _get_live_data(self) -> Dict[str, Any]:
        if "liveData" in self.root:
            return self.root["liveData"]
        raise MissingDataError

    def extract_competitions(self) -> Dict[Tuple[str, str], Dict[str, Any]]:
        """Return a dictionary with all available competitions.

        Returns
        -------
        dict
            A mapping between competion IDs and the information available about
            each competition in the data stream.
        """
        match_info = self._get_match_info()

# 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 _get_end_x(qualifiers: Dict[int, Any]) -> Optional[float]:
#     try:
#         # pass
#         if 140 in qualifiers:
#             return float(qualifiers[140])
#         # blocked shot
#         if 146 in qualifiers:
#             return float(qualifiers[146])
#         # passed the goal line
#         if 102 in qualifiers:
#             return float(100)
#         return None
#     except ValueError:
#         return None
# 
# def _get_end_y(qualifiers: Dict[int, Any]) -> Optional[float]:
#     try:
#         # pass
#         if 141 in qualifiers:
#             return float(qualifiers[141])
#         # blocked shot
#         if 147 in qualifiers:
#             return float(qualifiers[147])
#         # passed the goal line
#         if 102 in qualifiers:
#             return float(qualifiers[102])
#         return None
#     except ValueError:
#         return None
# 
# 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/ma3_json.py
from datetime import datetime
from typing import Any, Dict, List, Optional, Tuple
from ...base import MissingDataError
from .base import OptaJSONParser, _get_end_x, _get_end_y, assertget
import pandas as pd

    """

    _position_map = {
        1: "Goalkeeper",
        2: "Defender",
        3: "Midfielder",
        4: "Forward",
        5: "Substitute",
    }

    def _get_match_info(self) -> Dict[str, Any]:
        if "matchInfo" in self.root:
            return self.root["matchInfo"]
        raise MissingDataError

    def _get_live_data(self) -> Dict[str, Any]:
        if "liveData" in self.root:
            return self.root["liveData"]
        raise MissingDataError

    def extract_competitions(self) -> Dict[Tuple[str, str], Dict[str, Any]]:
        """Return a dictionary with all available competitions.

        Returns
        -------
        dict
            A mapping between competion IDs and the information available about
            each competition in the data stream.
        """
        match_info = self._get_match_info()

        season = assertget(match_info, "tournamentCalendar")