Ejemplo n.º 1
0
def main(league, time, standings, team, live, use12hour, players, output_format,
         output_file, upcoming, lookup, listcodes, apikey):
    """
    A CLI for live and past football scores from various football leagues.

    League codes:

    \b
    - CL: Champions League
    - PL: England Premier League
    - EL1: England League One
    - ELC: England Championship
    - FL1: French Ligue 1
    - FL2: French Ligue 2
    - BL: German Bundesliga
    - BL2: 2. Bundesliga
    - SA: Serie A
    - DED: Eredivisie
    - PPL: Primeira Liga
    - PD: Primera Division
    - SD: Segunda Division
    """
    global headers
    headers = {'X-Auth-Token': apikey}

    try:
        if output_format == 'stdout' and output_file:
            raise IncorrectParametersException('Printing output to stdout and '
                                               'saving to a file are mutually exclusive')
        writer = get_writer(output_format, output_file)

        if listcodes:
            list_team_codes()
            return

        if live:
            get_live_scores(writer, use12hour)
            return

        if standings:
            if not league:
                raise IncorrectParametersException('Please specify a league. '
                                                   'Example --standings --league=EPL')
            get_standings(league, writer)
            return

        if team:
            if lookup:
                map_team_id(team)
                return
            if players:
                get_team_players(team, writer)
                return
            else:
                get_team_scores(team, time, writer, upcoming, use12hour)
                return

        get_league_scores(league, time, writer, upcoming, use12hour)
    except IncorrectParametersException as e:
        click.secho(e.message, fg="red", bold=True)
Ejemplo n.º 2
0
def main(league, time, standings, team, live, players, output_format, output_file):
    """A CLI for live and past football scores from various football leagues"""
    try:
        if output_format == 'stdout' and output_file:
            raise IncorrectParametersException('Printing output to stdout and '
                                               'saving to a file are mutually exclusive')
        writer = get_writer(output_format, output_file)

        if live:
            get_live_scores(writer)
            return

        if standings:
            if not league:
                raise IncorrectParametersException('Please specify a league. '
                                                   'Example --standings --league=EPL')
            get_standings(league, writer)
            return

        if team:
            if players:
                get_team_players(team, writer)
                return
            else:
                get_team_scores(team, time, writer)
                return

        get_league_scores(league, time, writer)
    except IncorrectParametersException as e:
        click.secho(e.message, fg="red", bold=True)
Ejemplo n.º 3
0
def main(league, time, standings, team, live, use12hour, players, output_format, output_file, upcoming, lookup, listcodes, apikey):
    """A CLI for live and past football scores from various football leagues"""
    global headers
    headers = {
        'X-Auth-Token': apikey
    }
    try:
        if output_format == 'stdout' and output_file:
            raise IncorrectParametersException('Printing output to stdout and '
                                               'saving to a file are mutually exclusive')
        writer = get_writer(output_format, output_file)

        if listcodes:
            list_team_codes()
            return

        if live:
            get_live_scores(writer, use12hour)
            return

        if standings:
            if not league:
                raise IncorrectParametersException('Please specify a league. '
                                                   'Example --standings --league=EPL')
            get_standings(league, writer)
            return

        if team:
            if lookup:
                map_team_id(team)
                return
            if players:
                get_team_players(team, writer)
                return
            else:
                get_team_scores(team, time, writer, upcoming, use12hour)
                return

        get_league_scores(league, time, writer, upcoming, use12hour)
    except IncorrectParametersException as e:
        click.secho(e.message, fg="red", bold=True)
Ejemplo n.º 4
0
def main(league, time, standings, team, live, use12hour, players,
         output_format, output_file, upcoming, lookup, listcodes, apikey):
    """
    A CLI for live and past football scores from various football leagues.

    League codes:

    \b
    - CL: Champions League
    - PL: English Premier League
    - ELC: English Championship
    - EL1: English League One
    - FL1: French Ligue 1
    - FL2: French Ligue 2
    - BL: German Bundesliga
    - BL2: 2. Bundesliga
    - SA: Serie A
    - DED: Eredivisie
    - PPL: Primeira Liga
    - PD: Primera Division
    - SD: Segunda Division
    """
    headers = {'X-Auth-Token': apikey}

    try:
        if output_format == 'stdout' and output_file:
            raise IncorrectParametersException(
                'Printing output to stdout and '
                'saving to a file are mutually exclusive')
        writer = get_writer(output_format, output_file)
        rh = RequestHandler(headers, LEAGUE_IDS, TEAM_NAMES, writer)

        if listcodes:
            list_team_codes()
            return

        if live:
            rh.get_live_scores(use12hour)
            return

        if standings:
            if not league:
                raise IncorrectParametersException(
                    'Please specify a league. '
                    'Example --standings --league=PL')
            if league == 'CL':
                raise IncorrectParametersException(
                    'Standings for CL - '
                    'Champions League not supported')
            rh.get_standings(league)
            return

        if team:
            if lookup:
                map_team_id(team)
                return
            if players:
                rh.get_team_players(team)
                return
            else:
                rh.get_team_scores(team, time, upcoming, use12hour)
                return

        rh.get_league_scores(league, time, upcoming, use12hour)
    except IncorrectParametersException as e:
        click.secho(str(e), fg="red", bold=True)
Ejemplo n.º 5
0
def main(league, time, standings, extended, matchday, team, live, refresh,
         use12hour, players, output_format, output_file, upcoming, lookup,
         listcodes, listleagues, apikey):
    """
    A CLI for live and past football scores from various football leagues.

    League codes:

    \b
    - CL: Champions League
    - EPL: Premier League
    - EL1: League One
    - FL: Ligue 1
    - FL2: Ligue 2
    - BL: Bundesliga
    - BL2: 2. Bundesliga
    - BL3: 3. Liga
    - SA: Serie A
    - DED: Eredivisie
    - PPL: Primeira Liga
    - LLIGA: La Liga
    - SD: Segunda Division
    """
    global headers
    headers = {'X-Auth-Token': apikey}

    try:
        if output_format == 'stdout' and output_file:
            raise IncorrectParametersException(
                'Printing output to stdout and '
                'saving to a file are mutually exclusive')
        writer = get_writer(output_format, output_file)

        if listcodes:
            list_team_codes()
            return

        if listleagues:
            list_league_codes()
            return

        if live:
            if league:
                get_live_league(writer, use12hour, league, refresh)
            else:
                get_live_scores(writer, use12hour, refresh)
            return

        if standings:
            if not league:
                raise IncorrectParametersException(
                    'Please specify a league. '
                    'Example --standings --league=EPL')
            if matchday > 0:
                get_matchday_standings(league, writer, extended, matchday)
            else:
                get_standings(league, writer, extended)
            return

        if time < 1:
            raise IncorrectParametersException(
                'Please specify a time value greater than 0.')

        if team:
            if lookup:
                map_team_id(team)
                return
            if players:
                get_team_players(team, writer)
                return
            else:
                get_team_scores(team, time, writer, upcoming, use12hour)
                return

        get_league_scores(league, time, writer, upcoming, use12hour)
    except IncorrectParametersException as e:
        click.secho(e.message, fg="red", bold=True)