Esempio n. 1
0
def odds_match_values_interface(window, values):
    """
    :param window: Fenêtre principale PySimpleGUI
    :param values: Valeurs de la fenêtre principale
    :return: Affiche le résultat de la fonction odds_match dans l'interface
    """
    try:
        match = values["MATCHES_VALUES"][0]
        sport = values["SPORT_VALUES"][0]
        old_stdout = sys.stdout  # Memorize the default stdout stream
        sys.stdout = io.StringIO()
        odds_dict = odds_match(match, sport)[1]
        sys.stdout = old_stdout  # Put the old stream back in place
        odds = odds_dict["odds"]
        date = odds_dict["date"]
        if len(list(odds.values())[0]) == 2:
            for key in odds.keys():
                odds[key].insert(1, "-   ")
        table = []
        for key, value in odds.items():
            table.append([key] + list(map(str, value)))
        table.sort()
        window["ODDS_VALUES"].update(table, visible=True)
        if date:
            window["DATE_VALUES"].update(date.strftime("%A %d %B %Y %H:%M"), visible=True)
        else:
            window["DATE_VALUES"].update(visible=False)
        window["MATCH_VALUES"].update(match, visible=True)
        rate, infos_value = get_values(sb.ODDS[sport][match], 0)
        window["INFOS_VALUE_VALUES"].update("Value max : {}%".format(round(rate*100, 2)))
        window["INFOS_ODDS_VALUES"].update(" / ".join("{} @ {} (+{}%)".format(bookmaker, odd, round(r*100, 2)) for bookmaker, r, odd in infos_value))
        trj = trj_match(sb.ODDS[sport][match])[0]
        window["INFOS_TRJ_VALUES"].update("TRJ : {}%".format(round(trj*100, 3)))
    except (IndexError, ValueError) as _:
        pass
Esempio n. 2
0
def odds_match_interface(window, values):
    """
    :param window: Fenêtre principale PySimpleGUI
    :param values: Valeurs de la fenêtre principale
    :return: Affiche le résultat de la fonction odds_match dans l'interface
    """
    try:
        match = values["MATCHES_ODDS"][0]
        sport = values["SPORT_ODDS"][0]
        old_stdout = sys.stdout  # Memorize the default stdout stream
        sys.stdout = io.StringIO()
        odds_dict = odds_match(match, sport)[1]
        sys.stdout = old_stdout  # Put the old stream back in place
        odds = odds_dict["odds"]
        date = odds_dict["date"]
        if len(list(odds.values())[0]) == 2:
            for key in odds.keys():
                odds[key].insert(1, "-   ")
        table = []
        for key, value in odds.items():
            table.append([key] + list(map(str, value)))
        table.sort()
        window["ODDS_ODDS"].update(table, visible=True)
        if date:
            window["DATE_ODDS"].update(date.strftime("%A %d %B %Y %H:%M"),
                                       visible=True)
        else:
            window["DATE_ODDS"].update(visible=False)
        window["MATCH_ODDS"].update(match, visible=True)
        window["DELETE_ODDS"].update(visible=True)
    except IndexError:
        pass
def odds_match_interface(window, values):
    """
    :param window: Fenêtre principale PySimpleGUI
    :param values: Valeurs de la fenêtre principale
    :return: Affiche le résultat de la fonction odds_match dans l'interface
    """
    try:
        match = values["MATCHES_ODDS"][0]
        sport = values["SPORT_ODDS"][0]
        old_stdout = sys.stdout  # Memorize the default stdout stream
        sys.stdout = io.StringIO()
        odds_dict = odds_match(match, sport)[1]
        sys.stdout = old_stdout  # Put the old stream back in place
        odds = odds_dict["odds"]
        date = odds_dict["date"]
        if len(list(odds.values())[0]) == 2:
            for key in odds.keys():
                odds[key].insert(1, "-   ")
        table = []
        for key, value in odds.items():
            table.append([key] + list(map(str, value)))
        table.sort()
        window["ODDS_ODDS"].update(table, visible=True)
        if date:
            window["DATE_ODDS"].update(date.strftime("%A %d %B %Y %H:%M"),
                                       visible=True)
        else:
            window["DATE_ODDS"].update(visible=False)
        window["MATCH_ODDS"].update(match, visible=True)
        trj, bookmakers, best_odds = trj_match(sb.ODDS[sport][match])
        window["TRJ_ODDS"].update("TRJ : {}%".format(round(trj * 100, 3)))
        window["INFOS_ODDS"].update(" / ".join(
            bookmaker + " @ " + str(odd)
            for bookmaker, odd in zip(bookmakers, best_odds)))
        window["GOTO_SITE_ODDS"].update(visible=sb.BETA)
        window["DELETE_SITE_ODDS"].update(visible=True)
        window["DELETE_MATCH_ODDS"].update(visible=True)
    except IndexError:
        pass