Skip to content

Commit

Permalink
automatic trj sort
Browse files Browse the repository at this point in the history
  • Loading branch information
pretrehr committed Aug 11, 2021
1 parent 38815a0 commit 150c1a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
17 changes: 6 additions & 11 deletions interface_pysimplegui.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@
sg.Col([[sg.InputText(key='SEARCH_ODDS', size=(40, 1), enable_events=True)],
[sg.Listbox([], size=(40, 12), key="MATCHES_ODDS", enable_events=True)],
[sg.Button("Trier par TRJ", key="TRJ_SORT_ODDS"),
sg.Button("Trier par nom", key="NAME_SORT_ODDS")]]),
sg.Button("Trier par nom", key="NAME_SORT_ODDS"),
sg.Button("Ajouter match", key="ADD_MATCH_ODDS")]]),
sg.Col([[sg.Text("", size=(30, 1), key="MATCH_ODDS", visible=False)],
[sg.Text("", size=(30, 1), key="TRJ_ODDS")],
[sg.Text("", size=(30, 3), key="INFOS_ODDS")],
Expand Down Expand Up @@ -950,23 +951,17 @@ def stakes_thread():
elif event == "RELOAD_ODDS_GAGNANT":
sb.ODDS = load_odds(PATH_DATA)
elif event == "NAME_SORT_ODDS":
try:
matches = sorted(list(sb.ODDS[values["SPORT_ODDS"][0]]))
window['MATCHES_ODDS'].update(values=matches)
except KeyError:
window['MATCHES_ODDS'].update(values=[])
elif event == "SEARCH_ODDS":
try:
matches = sorted(list([x for x in sb.ODDS[values["SPORT_ODDS"][0]] if values["SEARCH_ODDS"].lower() in x.lower()]))
window['MATCHES_ODDS'].update(values=matches)
except KeyError:
window['MATCHES_ODDS'].update(values=[])
elif event == "MATCHES_ODDS":
odds_match_interface(window, values)
elif event == "SPORT_ODDS" or event == "TRJ_SORT_ODDS":
elif event == "SPORT_ODDS" or event == "TRJ_SORT_ODDS" or event == "SEARCH_ODDS":
try:
window["OUTCOME_ODDS_N"].update(visible=get_nb_outcomes(values["SPORT_ODDS"][0])==3)
matches = sorted(list(sb.ODDS[values["SPORT_ODDS"][0]]), key=lambda x:trj_match(sb.ODDS[values["SPORT_ODDS"][0]][x])[0], reverse=True)
matches = sorted(list([x for x in sb.ODDS[values["SPORT_ODDS"][0]] if values["SEARCH_ODDS"].lower() in x.lower()]), key=lambda x:trj_match(sb.ODDS[values["SPORT_ODDS"][0]][x])[0], reverse=True)
window['MATCHES_ODDS'].update(values=matches)
except KeyError:
window['MATCHES_ODDS'].update(values=[])
Expand Down Expand Up @@ -1009,7 +1004,7 @@ def stakes_thread():
window["N_RES_COMBI_OPT_"+str(i)].update(visible=True)
for i in range(9):
if sport in sb.ODDS:
matches = sorted(list([x + " / " + str(sb.ODDS[sport][x]["date"]) for x in sb.ODDS[sport]]))
matches = sorted(list([x + " / " + str(sb.ODDS[sport][x]["date"]) for x in sb.ODDS[sport]]), key=lambda x : x.split(" / ")[-1])
window['MATCH_COMBI_OPT_'+str(i)].update(values=matches)
else:
window['MATCH_COMBI_OPT_'+str(i)].update(values=[])
Expand All @@ -1021,7 +1016,7 @@ def stakes_thread():
sport = values["SPORT_COMBI_OPT"][0]
i = event.split("_")[-1]
if sport in sb.ODDS:
matches = sorted(list([x + " / " + str(sb.ODDS[sport][x]["date"]) for x in sb.ODDS[sport] if values["SEARCH_MATCH_COMBI_OPT_"+i].lower() in x.lower()]))
matches = sorted(list([x + " / " + str(sb.ODDS[sport][x]["date"]) for x in sb.ODDS[sport] if values["SEARCH_MATCH_COMBI_OPT_"+i].lower() in x.lower()]), key=lambda x : x.split(" / ")[-1])
window['MATCH_COMBI_OPT_' + i].update(values=matches)
elif event in (None, 'Quitter'): # if user closes window or clicks cancel
break
Expand Down
2 changes: 1 addition & 1 deletion sportsbetting/interface_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def delete_odds_interface(window, values):
match = values["MATCHES_ODDS"][0]
sport = values["SPORT_ODDS"][0]
del sb.ODDS[sport][match]
matches = sorted(list(sb.ODDS[sport]))
matches = sorted(list([x for x in sb.ODDS[values["SPORT_ODDS"][0]] if values["SEARCH_ODDS"].lower() in x.lower()]), key=lambda x:trj_match(sb.ODDS[values["SPORT_ODDS"][0]][x])[0], reverse=True)
window['MATCHES_ODDS'].update(values=matches)
window["MATCHES"].update(values=matches)
window["ODDS_ODDS"].update(visible=False)
Expand Down

0 comments on commit 150c1a2

Please sign in to comment.