def get_race_name(rid, include_flag=True, include_country=True, line_br=None, use_shortened=False, include_year=False): """ Gets the stylized version of the given race's name :param rid: Race ID :param include_flag: Whether to include the nationality flag in the constructor's name :param include_country: Whether to use the full race name or just the country name :param line_br: Character to use for line break, or None if not desired :param use_shortened: Use shortened version of GP name :param include_year: Whether to include the year in the name, only works if `use_shortened` and `line_br` are both False :return: String """ global circuits, races if circuits is None: circuits = load_circuits() if races is None: races = load_races() race = races.loc[rid] circuit = circuits.loc[race["circuitId"]] name = circuit["country"] if include_country else race["name"] if use_shortened: name = name[:3].upper() if include_flag: nat = circuit["country"].lower() if nat in NATIONALITY_TO_FLAG.index: flag_t = NATIONALITY_TO_FLAG.loc[nat, "flag"] if line_br: name = flag.flagize(f"{name} {line_br} :{flag_t}:") else: name = flag.flagize(f":{flag_t}: " + name) else: logging.warning(f"Unknown nationality {nat}, race ID: {rid}") if include_year: name = str(race["year"]) + " " + name return name
import logging import traceback from data_loading.data_loader import load_races, load_seasons, load_driver_standings, load_constructor_standings, \ load_results, load_lap_times, load_qualifying, load_fastest_lap_data from mode.year import get_layout, generate_wdc_plot, generate_wcc_plot, generate_teams_and_drivers_table, \ generate_races_info_table, generate_wdc_results_table, generate_dnf_table, generate_win_plots, \ generate_mltr_position_scatter, generate_msp_position_scatter, generate_spvfp_scatter, generate_wcc_results_table, \ generate_wins_pie_plots import time import pandas as pd # Biggest JOKE of a "unit test" but it works from utils import time_decorator races = load_races() error_ids = [] times = {"yid": [], "time": []} logger = logging.getLogger() logger.disabled = True seasons = load_seasons() driver_standings = load_driver_standings() constructor_standings = load_constructor_standings() results = load_results() lap_times = load_lap_times() qualifying = load_qualifying() fastest_lap_data = load_fastest_lap_data() year_id = 2017 # Generate some useful slices