multigp_toolkit.rsimporter#
Import Data from RaceSync
Attributes#
Classes#
Actions for importing data from RaceSync |
Module Contents#
- multigp_toolkit.rsimporter.T#
Generic type variable
- multigp_toolkit.rsimporter.logger#
Logger for the module
- class multigp_toolkit.rsimporter.RaceSyncImporter(rhapi, multigp)#
Actions for importing data from RaceSync
- Parameters:
rhapi (RHAPI.RHAPI)
multigp (multigp_toolkit.multigpapi.MultiGPAPI)
- _rhapi#
A stored instace of the RHAPI module
- _multigp#
A stored instace of the MultiGPAPI module
- _zippq_lock#
Lock for ensuring zippyq pulls
- pilot_search(mgp_pilot, *, update_attrs=False)#
Attempt to match a MultiGP pilot with a RH pilot from a provided list. Create a new pilot if a match is not found.
- Parameters:
db_pilots – The list of RH pilots to use for matching
mgp_pilot (dict[str, T]) – The MultiGP pilot to attempt to match
update_attrs (bool) – Update the pilot attributes even when seaching for pilot
- Returns:
The id of the RH pilot that was either matched or created
- Return type:
int
- _generate_gq_format_checks(race_format, mgp_format)#
Lazily run checks for global qualifier conditions
- Parameters:
race_format (Database.RaceFormat) – The database format to check
mgp_format (multigp_toolkit.enums.MGPFormat) – The MultiGP format to match to the race_format
- Yield:
The status of each check
- Return type:
collections.abc.Generator[bool, None, None]
- format_search(db_formats, mgp_format)#
Attempt to match a MultiGP format with a RH format from a provided list. Create a new format if a match is not found.
- Parameters:
db_formats (list[Database.RaceFormat]) – The list of RH formats to use for matching
mgp_format (multigp_toolkit.enums.MGPFormat) – The MultiGP format to match
- Returns:
The id of the RH format that was either matched or created.
- Return type:
int
- fprofile_search(frequencyset)#
Search the database for a matching frequency profile. Creates a new profile if not found. Sets the matched or created profile as active.
- Parameters:
frequencyset (dict[str, list]) – The frequency set to search for in the
- Return type:
int
database :return: The id of the frequency set
- import_pilots(_args=None)#
Imports pilots from the race selected in the RHUI.
- Parameters:
_args (Union[dict, None]) – Args passed from the event call, defaults to {}
- Return type:
None
- _generate_format_from_data(race_data)#
Generates the format from the race data
- Parameters:
race_data (dict[str, T]) – RaceSync race data
- Returns:
The generated race format or None
- Return type:
Union[multigp_toolkit.enums.MGPFormat, None]
- _generate_race_format(race_data)#
Parse the race data from RaceSync. Use it to find a format in the RH database. If format not found, add a new format.
- Parameters:
race_data (dict[str, T]) – RaceSync race data
- Returns:
The found or created format id paired with the MultiGP race format.
- Return type:
Union[tuple[int, multigp_toolkit.enums.MGPFormat], None]
None if unable to reconize the format from MultiGP.
- _setup_raceclass_heats(raceclass_id, heat_data, heat_name=None)#
Setup heats for imported raceclass
- Parameters:
race_class – The raceclass to save to
heats – The heat data from MultiGP
raceclass_id (Database.RaceClass)
heat_data (list)
heat_name (Union[str, None])
- Returns:
The last heat generated from the schedule
- Return type:
Database.Heat
- _setup_populated_rounds(selected_race, format_data, race_data)#
Setup a new raceclass with predefined heat data from MultiGP
- Parameters:
selected_race (int) – The MultiGP race id
format_id – The id of the format to set the class to.
race_data (dict[str, T]) – Downloaded MultiGP race data
format_data (tuple[int, multigp_toolkit.enums.MGPFormat])
- Return type:
None
- _run_seat_check(schedule_data)#
Checks to see if the number of slots on the MultiGP race exceeds the number of nodes installed on the timer
- Parameters:
race_data – The race schedule from MultiGP
schedule_data (dict)
- Returns:
The status of the check
- Return type:
bool
- import_class(selected_race, race_data)#
Setup a new raceclass within the RHUI based on the import MultiGP race(s).
- Parameters:
selected_race (int) – The id of the MultiGP race
race_data (dict[str, T]) – The imported race data
- Return type:
None
- zippyq(raceclass_id, selected_race, round_num)#
Imports a single ZippyQ round
- Parameters:
raceclass_id (int) – The raceclass to import the ZippyQ round into
selected_race (str) – The MultiGP race to import the ZippyQ from
round_num (int) – The round number to pull from RaceSync
- Returns:
The import ZippyQ round as a Heat or None if failed
- Return type:
Union[Database.Heat, None]
to import.
- manual_zippyq(_args=None)#
Used to manually trigger a ZippyQ import from the RHUI
- Parameters:
_args (Union[dict, None]) – Args passed from the event call, defaults to {}
- Return type:
None
- auto_zippyq(args)#
Automatically import the next ZippyQ round into the same race class as the race that tiggered the import.
- Parameters:
args (dict) – Args passed from the event call, defaults to {}
- Return type:
None