# Path: socceraction/data/base.py
# class EventDataLoader(ABC):
#     """Load event data either from a remote location or from a local folder.
# 
#     Parameters
#     ----------
#     root : str
#         Root-path of the data.
#     getter : str
#         "remote" or "local"
#     """
# 
#     @abstractmethod
#     def competitions(self) -> DataFrame[Any]:
#         """Return a dataframe with all available competitions and seasons.
# 
#         Returns
#         -------
#         pd.DataFrame
#             A dataframe containing all available competitions and seasons. See
#             :class:`~socceraction.spadl.base.CompetitionSchema` for the schema.
#         """
# 
#     @abstractmethod
#     def games(self, competition_id: int, season_id: int) -> DataFrame[Any]:
#         """Return a dataframe with all available games in a season.
# 
#         Parameters
#         ----------
#         competition_id : int
#             The ID of the competition.
#         season_id : int
#             The ID of the season.
# 
#         Returns
#         -------
#         pd.DataFrame
#             A dataframe containing all available games. See
#             :class:`~socceraction.spadl.base.GameSchema` for the schema.
#         """
# 
#     @abstractmethod
#     def teams(self, game_id: int) -> DataFrame[Any]:
#         """Return a dataframe with both teams that participated in a game.
# 
#         Parameters
#         ----------
#         game_id : int
#             The ID of the game.
# 
#         Returns
#         -------
#         pd.DataFrame
#             A dataframe containing both teams. See
#             :class:`~socceraction.spadl.base.TeamSchema` for the schema.
#         """
# 
#     @abstractmethod
#     def players(self, game_id: int) -> DataFrame[Any]:
#         """Return a dataframe with all players that participated in a game.
# 
#         Parameters
#         ----------
#         game_id : int
#             The ID of the game.
# 
#         Returns
#         -------
#         pd.DataFrame
#             A dataframe containing all players. See
#             :class:`~socceraction.spadl.base.PlayerSchema` for the schema.
#         """
# 
#     @abstractmethod
#     def events(self, game_id: int) -> DataFrame[Any]:
#         """Return a dataframe with the event stream of a game.
# 
#         Parameters
#         ----------
#         game_id : int
#             The ID of the game.
# 
#         Returns
#         -------
#         pd.DataFrame
#             A dataframe containing the event stream. See
#             :class:`~socceraction.spadl.base.EventSchema` for the schema.
#         """
# 
# class MissingDataError(Exception):
#     """Exception raised when a field is missing in the input data."""
# 
# class ParseError(Exception):
#     """Exception raised when a file is not correctly formatted."""
# 
# def _localloadjson(path: str) -> JSONType:
#     """Load a dictionary from a JSON's filepath.
# 
#     Parameters
#     ----------
#     path : str
#         JSON's filepath.
# 
#     Returns
#     -------
#     JSONType
#         A dictionary with the data loaded.
#     """
#     with open(path, 'rt', encoding='utf-8') as fh:
#         return json.load(fh)
# 
# def _remoteloadjson(path: str) -> JSONType:
#     """Load JSON data from a URL.
# 
#     Parameters
#     ----------
#     path : str
#         URL of the data source.
# 
#     Returns
#     -------
#     JSONType
#         A dictionary with the loaded JSON data.
#     """
#     return json.loads(urlopen(path).read())
# 
# Path: socceraction/data/wyscout/schema.py
# class WyscoutCompetitionSchema(CompetitionSchema):
#     """Definition of a dataframe containing a list of competitions and seasons."""
# 
#     country_name: Series[str]
#     competition_gender: Series[str]
# 
# class WyscoutEventSchema(EventSchema):
#     """Definition of a dataframe containing event stream data of a game."""
# 
#     milliseconds: Series[float]
#     subtype_id: Series[int]
#     subtype_name: Series[str]
#     positions: Series[Object]
#     tags: Series[Object]
# 
# class WyscoutGameSchema(GameSchema):
#     """Definition of a dataframe containing a list of games."""
# 
# class WyscoutPlayerSchema(PlayerSchema):
#     """Definition of a dataframe containing the list of teams of a game."""
# 
#     firstname: Series[str]
#     lastname: Series[str]
#     nickname: Series[str] = pa.Field(nullable=True)
#     birth_date: Series[DateTime] = pa.Field(nullable=True)
# 
# class WyscoutTeamSchema(TeamSchema):
#     """Definition of a dataframe containing the list of players of a game."""
# 
#     team_name_short: Series[str]


import glob
import os
import re
import warnings
import pandas as pd  # type: ignore
from pathlib import Path
from typing import Any, Dict, List, Optional, cast
from urllib.parse import urlparse
from urllib.request import urlopen, urlretrieve
from zipfile import ZipFile, is_zipfile
from pandera.typing import DataFrame
from ..base import (
    EventDataLoader,
    MissingDataError,
    ParseError,
    _localloadjson,
    _remoteloadjson,
)
from .schema import (
    WyscoutCompetitionSchema,
    WyscoutEventSchema,
    WyscoutGameSchema,
    WyscoutPlayerSchema,
    WyscoutTeamSchema,
)
            {
                'competitions': 'competitions',
                'seasons': 'competitions/{season_id}/seasons',
                'games': 'seasons/{season_id}/matches',
                'events': 'matches/{game_id}/events'
            }

        The fefault feeds for a "local" getter are::

            {
                'competitions': 'competitions.json',
                'seasons': 'seasons_{competition_id}.json',
                'games': 'matches_{season_id}.json',
                'events': 'matches/events_{game_id}.json',
            }

    """

    _wyscout_api: str = 'https://apirest.wyscout.com/v2/'

    def __init__(
        self,
        root: str = _wyscout_api,
        getter: str = 'remote',
        feeds: Optional[Dict[str, str]] = None,
    ) -> None:
        self.root = root
        if getter == 'remote':
            self.get = _remoteloadjson
        elif getter == 'local':

# Path: socceraction/data/base.py
# class EventDataLoader(ABC):
#     """Load event data either from a remote location or from a local folder.
# 
#     Parameters
#     ----------
#     root : str
#         Root-path of the data.
#     getter : str
#         "remote" or "local"
#     """
# 
#     @abstractmethod
#     def competitions(self) -> DataFrame[Any]:
#         """Return a dataframe with all available competitions and seasons.
# 
#         Returns
#         -------
#         pd.DataFrame
#             A dataframe containing all available competitions and seasons. See
#             :class:`~socceraction.spadl.base.CompetitionSchema` for the schema.
#         """
# 
#     @abstractmethod
#     def games(self, competition_id: int, season_id: int) -> DataFrame[Any]:
#         """Return a dataframe with all available games in a season.
# 
#         Parameters
#         ----------
#         competition_id : int
#             The ID of the competition.
#         season_id : int
#             The ID of the season.
# 
#         Returns
#         -------
#         pd.DataFrame
#             A dataframe containing all available games. See
#             :class:`~socceraction.spadl.base.GameSchema` for the schema.
#         """
# 
#     @abstractmethod
#     def teams(self, game_id: int) -> DataFrame[Any]:
#         """Return a dataframe with both teams that participated in a game.
# 
#         Parameters
#         ----------
#         game_id : int
#             The ID of the game.
# 
#         Returns
#         -------
#         pd.DataFrame
#             A dataframe containing both teams. See
#             :class:`~socceraction.spadl.base.TeamSchema` for the schema.
#         """
# 
#     @abstractmethod
#     def players(self, game_id: int) -> DataFrame[Any]:
#         """Return a dataframe with all players that participated in a game.
# 
#         Parameters
#         ----------
#         game_id : int
#             The ID of the game.
# 
#         Returns
#         -------
#         pd.DataFrame
#             A dataframe containing all players. See
#             :class:`~socceraction.spadl.base.PlayerSchema` for the schema.
#         """
# 
#     @abstractmethod
#     def events(self, game_id: int) -> DataFrame[Any]:
#         """Return a dataframe with the event stream of a game.
# 
#         Parameters
#         ----------
#         game_id : int
#             The ID of the game.
# 
#         Returns
#         -------
#         pd.DataFrame
#             A dataframe containing the event stream. See
#             :class:`~socceraction.spadl.base.EventSchema` for the schema.
#         """
# 
# class MissingDataError(Exception):
#     """Exception raised when a field is missing in the input data."""
# 
# class ParseError(Exception):
#     """Exception raised when a file is not correctly formatted."""
# 
# def _localloadjson(path: str) -> JSONType:
#     """Load a dictionary from a JSON's filepath.
# 
#     Parameters
#     ----------
#     path : str
#         JSON's filepath.
# 
#     Returns
#     -------
#     JSONType
#         A dictionary with the data loaded.
#     """
#     with open(path, 'rt', encoding='utf-8') as fh:
#         return json.load(fh)
# 
# def _remoteloadjson(path: str) -> JSONType:
#     """Load JSON data from a URL.
# 
#     Parameters
#     ----------
#     path : str
#         URL of the data source.
# 
#     Returns
#     -------
#     JSONType
#         A dictionary with the loaded JSON data.
#     """
#     return json.loads(urlopen(path).read())
# 
# Path: socceraction/data/wyscout/schema.py
# class WyscoutCompetitionSchema(CompetitionSchema):
#     """Definition of a dataframe containing a list of competitions and seasons."""
# 
#     country_name: Series[str]
#     competition_gender: Series[str]
# 
# class WyscoutEventSchema(EventSchema):
#     """Definition of a dataframe containing event stream data of a game."""
# 
#     milliseconds: Series[float]
#     subtype_id: Series[int]
#     subtype_name: Series[str]
#     positions: Series[Object]
#     tags: Series[Object]
# 
# class WyscoutGameSchema(GameSchema):
#     """Definition of a dataframe containing a list of games."""
# 
# class WyscoutPlayerSchema(PlayerSchema):
#     """Definition of a dataframe containing the list of teams of a game."""
# 
#     firstname: Series[str]
#     lastname: Series[str]
#     nickname: Series[str] = pa.Field(nullable=True)
#     birth_date: Series[DateTime] = pa.Field(nullable=True)
# 
# class WyscoutTeamSchema(TeamSchema):
#     """Definition of a dataframe containing the list of players of a game."""
# 
#     team_name_short: Series[str]


# Path: socceraction/data/wyscout/loader.py
import glob
import os
import re
import warnings
import pandas as pd  # type: ignore
from pathlib import Path
from typing import Any, Dict, List, Optional, cast
from urllib.parse import urlparse
from urllib.request import urlopen, urlretrieve
from zipfile import ZipFile, is_zipfile
from pandera.typing import DataFrame
from ..base import (
    EventDataLoader,
    MissingDataError,
    ParseError,
    _localloadjson,
    _remoteloadjson,
)
from .schema import (
    WyscoutCompetitionSchema,
    WyscoutEventSchema,
    WyscoutGameSchema,
    WyscoutPlayerSchema,
    WyscoutTeamSchema,
)

            {
                'competitions': 'competitions',
                'seasons': 'competitions/{season_id}/seasons',
                'games': 'seasons/{season_id}/matches',
                'events': 'matches/{game_id}/events'
            }

        The fefault feeds for a "local" getter are::

            {
                'competitions': 'competitions.json',
                'seasons': 'seasons_{competition_id}.json',
                'games': 'matches_{season_id}.json',
                'events': 'matches/events_{game_id}.json',
            }

    """

    _wyscout_api: str = 'https://apirest.wyscout.com/v2/'

    def __init__(
        self,
        root: str = _wyscout_api,
        getter: str = 'remote',
        feeds: Optional[Dict[str, str]] = None,
    ) -> None:
        self.root = root
        if getter == 'remote':
            self.get = _remoteloadjson
        elif getter == 'local':

            self.get = _localloadjson