Пример #1
0
def save_team_names_to_files():
    teams = get_teams_from_xml(ET.parse(xml_file_path).getroot())
    for counter, team in enumerate(teams):
        write_one_line_to_file(f"{path_to_save}/druzyna_{counter}_name.txt",
                               team.teamname)
        write_one_line_to_file(f"{path_to_save}/druzyna_{counter}_id.txt",
                               team.id)
    make_info_log("Zapisano nazwy oraz id drużyn")
Пример #2
0
def save_best_players_to_files():
    teams = get_teams_from_xml(ET.parse(xml_file_path).getroot())
    for counter, team in enumerate(teams):
        value = "druzyna_" + str(counter)
        player = get_best_player_from_team_line(team)
        write_one_line_to_file(
            f"{path_to_save}/{value}_best_player.txt",
            f"{team.teamname}\n{player.number} {player.name} {player.surname} {player.points} pkt. {player.eval} eval {player.fgm2}/{player.fga2} za 2 {player.fgm3}/{player.fga3} za 3 {player.rebounds} zb. {player.assists} as. {player.steals} prz."
        )
Пример #3
0
def save_logos():
    teams = get_teams_from_xml(ET.parse(xml_file_path).getroot())
    try:
        logo_guest = get_logo_path_by_team_id(teams[0].id)
        copy_file(logo_guest, f"{resources_path}\\photos\\druzyna_0_logo.png")
        copy_file(logo_guest, f"{logos_save_path}\\gosc_logo.png")
        make_info_log("Skopiowano logo gościa do odpowiednich folderów")
    except FileNotFoundError:
        traceback.print_exc()
        make_error_log(
            f"Logo gospodarza o id {teams[0].id} nieznalezione, powinno być pod nazwą {teams[0].id}.png w katalogu 'resources/logos'"
        )

    try:
        logo_host = get_logo_path_by_team_id(teams[1].id)
        copy_file(logo_host, f"{resources_path}\\photos\\druzyna_1_logo.png")
        copy_file(logo_host, f"{logos_save_path}\\gospodarz_logo.png")
        make_info_log("Skopiowano logo gospodarza do odpowiednich folderów")
    except FileNotFoundError:
        make_error_log(
            f"Logo gospodarza o id {teams[1].id} nieznalezione, powinno być pod nazwą {teams[1].id}.png w katalogu 'resources/logos'"
        )
Пример #4
0
def save_random_stat_to_file():
    teams = get_teams_from_xml(ET.parse(xml_file_path).getroot())
    object_type = get_type_of_random_object()
    if (not get_status(ET.parse(xml_file_path).getroot())):
        make_info_log(f"Losowa statystyka nie zapisana, czas stoi w miejscu")
        return
    if (object_type == 1):
        remove_player_photo()
        random_possible_stat = random.choice(get_team_probabilities())
        random_stat = f"{getattr(model, f'get_{random_possible_stat}_stat')(teams[0].id, getattr(teams[0], random_possible_stat), teams[0])}, {getattr(model, f'get_{random_possible_stat}_stat')(teams[1].id, getattr(teams[1], random_possible_stat), teams[1])}"
    elif (object_type == 2):
        random_possible_stat = random.choice(get_player_probabilities())
        random_player = get_player_from_teams_depends_on_stat_type(
            teams, random_possible_stat)
        if (look_for_player_photos):
            update_player_photo(random_player)
        random_stat = getattr(
            model, f'get_{random_possible_stat}_stat'
        )(f'{random_player.short_teamname}: {random_player.number} {random_player.name} {random_player.surname}',
          getattr(random_player, random_possible_stat), random_player)
    start = time.time()
    write_one_line_to_file(f"{path_to_save}/random_stat.txt", random_stat)
    end = time.time()
    make_info_log(f"Losowa statystyka - {random_stat}")
Пример #5
0
def save_players_stats_to_file():
    root = ET.parse(xml_file_path).getroot()
    teams = get_teams_from_xml(root)
    for counter, team in enumerate(teams):
        graphic_editor = GraphicEditor()
        if (get_status(root)):
            try:
                graphic_editor.edit_photo(
                    counter, resources_path, team,
                    f"{path_to_save}/druzyna_{counter}_players_stats.png",
                    fontname)
                make_info_log(
                    f"Zaktualizowano grafikę ze statystykami zawodników drużyny nr {counter}"
                )
            except OSError:
                make_error_log(
                    f"Wątek ze skanowaniem statystyk nie mógł odnaleźć fontu")
            write_one_line_to_file(
                f"{path_to_save}/druzyna_{counter}_players_stats.txt",
                f"{team.teamname}{get_players_stats_string_to_txt(team)}")
        else:
            make_info_log(
                f"Nie zaktualizowano grafiki ze statystykami zawodników drużyny nr {counter}, czas stoi w miejscu"
            )
Пример #6
0
def save_timeouts_to_file():
    teams = get_teams_from_xml(ET.parse(xml_file_path).getroot())
    for counter, team in enumerate(teams):
        write_one_line_to_file(
            f"{path_to_save}/druzyna_{counter}_timeouts.txt",
            str(team.timeouts))
Пример #7
0
def save_players_to_file():
    teams = get_teams_from_xml(ET.parse(xml_file_path).getroot())
    for counter, team in enumerate(teams):
        write_one_line_to_file(f"{path_to_save}/druzyna_{counter}.txt",
                               f"{get_players_string(team.players)}")
    make_info_log("Zapisano zawodników")
Пример #8
0
def save_team_stats_to_file():
    teams = get_teams_from_xml(ET.parse(xml_file_path).getroot())
    for counter, team in enumerate(teams):
        write_one_line_to_file(
            f"{path_to_save}/druzyna_{counter}_team_stats.txt",
            f"{team.teamname}{get_team_stat_string(team)}")