from typing import List import gradio as gr MEDIA_PATH = "medias/" MEDIA_FILE_TYPE = ".png" def get_content(file_name: str) -> str: with open(file_name, "r", encoding="utf-8") as file: content = file.read() return content def get_player_partners(player_info: gr.State) -> List[str]: return [ f"{MEDIA_PATH}{partner}{MEDIA_FILE_TYPE}" for partner in player_info["partners"] ] def get_player_badges(player_info: gr.State) -> List[str]: return [f"{MEDIA_PATH}{badge}{MEDIA_FILE_TYPE}" for badge in player_info["badges"]] def get_player_achievement_logs(player_info: gr.State) -> List[str]: log_template = """

{player_log}

""" return [ log_template.format(player_log=player_log) for player_log in player_info["achievement_logs"] ] def get_player_achievement_logs_html(player_info: gr.State) -> str: achievement_logs = "".join(get_player_achievement_logs(player_info)) template_content = get_content("htmls/achievement_template.html") return template_content.replace("{logs}", achievement_logs)