def main(): try: args = parse_command_line_args() log.initialize( co.logname(__file__, instance=args.instance), file_level="debug", console_level="info", ) log.info( "\n--------------------------------------------------------\nstarted" ) dba.open_connect() oncourt_players.initialize() ratings.initialize("wta", rtg_names=("elo", )) ratings.initialize("atp", rtg_names=("elo", )) ratings.Rating.register_rtg_name("elo_alt") app = Application( wta_players=oncourt_players.players("wta"), atp_players=oncourt_players.players("atp"), ) app.master.title("Live") app.mainloop() log.info("sex: " + app.sex()) log.info("left_player: " + app.left_player_name()) log.info("right_player: " + app.right_player_name()) log.info("score: {}".format(app.score())) log.info("level: {}".format(app.level())) log.info("surface: {}".format(app.surface())) dba.close_connect() return 0 except Exception as err: log.error("{0} [{1}]".format(err, err.__class__.__name__), exc_info=True) return 1
def read_pers_det(self, sex): if self.ident is None: return player = co.find_first(oncourt_players.players(sex), lambda p: p.ident == self.ident) if player is not None: self.lefty = player.lefty
def __init__(self, sex, chance_thresholds=(0.55, 0.60, 0.65, 0.70)): # (chance_threshold, pid) -> WinLoss self.data_dict = defaultdict(st.WinLoss) self.sex = sex self.actual_players = oncourt_players.players(sex) self.chance_thresholds = chance_thresholds self.min_size = 15 if sex == "wta" else 20
def test_wta_kerber_lefty(self): plrs = players("wta") results = [p for p in plrs if p.ident == 4076] self.assertEqual(len(results), 1) if len(results) == 1: kerber = results[0] self.assertTrue('Kerber' in kerber.name) self.assertTrue(kerber.lefty)
def test_atp_exist_lefty_player(self): plrs = players("atp") lefty_cnt = sum([1 for p in plrs if p.lefty]) self.assertTrue(lefty_cnt >= 5) our_plrs = [ p for p in plrs if p.name == "Gerald Melzer" and p.cou == "AUT" ] self.assertTrue(len(our_plrs) == 1) if our_plrs: self.assertTrue(our_plrs[0].lefty)
def identify_player(company_name, sex, player_short_name, cou=None): if company_name == "FS": company_key = "flashscore" else: raise co.TennisError( "unexpected company_name '{}'".format(company_name)) if cou is None: player = co.find_first( oncourt_players.players(sex), lambda p: p.disp_name(company_key) == player_short_name, ) else: player = co.find_first( oncourt_players.players(sex), lambda p: p.cou == cou and p.disp_name(company_key) == player_short_name, ) if player is not None: return player abbrname = AbbrName(player_short_name) return abbrname.find_player(oncourt_players.players(sex), sex)
def _find_player(sex: str, disp_name: str, cou: str): cache = wta_today_players_cache if sex == "wta" else atp_today_players_cache if cache: return cache[(disp_name, cou)] if deep_find_player_mode: plr = player_name_ident.identify_player("FS", sex, disp_name, cou) if init_players_cache_mode: if plr is not None: cache[(disp_name, cou)] = plr else: log.warn("fail player ident {} '{}' {}".format( sex, disp_name, cou)) return plr else: return co.find_first( oncourt_players.players(sex), lambda p: p.cou == cou and p.disp_name("flashscore") == disp_name, )
def __init__(self, sex): self.dec_sets_from_player = defaultdict(st.WinLoss) self.sex = sex self.actual_players = oncourt_players.players(sex)
def test_wta_count_hand_players(self): plrs = players("wta") cnt = sum([1 for p in plrs if p.lefty is not None]) print(f"wta n_hand={cnt}") self.assertTrue(cnt >= 400)
def test_min_players(self): plrs = players("atp") self.assertGreaterEqual(len(plrs), 1000)
def __init__(self, sex, min_size, max_size): self.sex = sex self.min_size = min_size self.max_size = max_size self.actual_players = oncourt_players.players(sex) self.plr_val = []
def setUp(self): self.players_wta = oncourt_players.players("wta") self.players_atp = oncourt_players.players("atp")