multigp_toolkit.rsimporter
==========================

.. py:module:: multigp_toolkit.rsimporter

.. autoapi-nested-parse::

   Import Data from RaceSync



Attributes
----------

.. autoapisummary::

   multigp_toolkit.rsimporter.T
   multigp_toolkit.rsimporter.logger


Classes
-------

.. autoapisummary::

   multigp_toolkit.rsimporter.RaceSyncImporter


Module Contents
---------------

.. py:data:: T

   Generic type variable


.. py:data:: logger

   Logger for the module


.. py:class:: RaceSyncImporter(rhapi, multigp)

   Actions for importing data from RaceSync


   .. py:attribute:: _rhapi

      A stored instace of the RHAPI module



   .. py:attribute:: _multigp

      A stored instace of the MultiGPAPI module



   .. py:attribute:: _zippq_lock

      Lock for ensuring zippyq pulls



   .. py:method:: 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.

      :param db_pilots: The list of RH pilots to use for matching
      :param mgp_pilot: The MultiGP pilot to attempt to match
      :param update_attrs: Update the pilot attributes even when seaching for pilot
      :return: The id of the RH pilot that was either matched or created



   .. py:method:: _generate_gq_format_checks(race_format, mgp_format)

      Lazily run checks for global qualifier conditions

      :param race_format: The database format to check
      :param mgp_format: The MultiGP format to match to the race_format
      :yield: The status of each check



   .. py:method:: 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.

      :param db_formats: The list of RH formats to use for matching
      :param mgp_format: The MultiGP format to match
      :return: The id of the RH format that was either matched or created.



   .. py:method:: 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.

      :param frequencyset: The frequency set to search for in the
      database
      :return: The id of the frequency set



   .. py:method:: import_pilots(_args = None)

      Imports pilots from the race selected in the RHUI.

      :param _args: Args passed from the event call, defaults to {}



   .. py:method:: _generate_format_from_data(race_data)

      Generates the format from the race data

      :param race_data: RaceSync race data
      :return: The generated race format or None



   .. py:method:: _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.

      :param race_data: RaceSync race data
      :return: The found or created format id paired with the MultiGP race format.
      None if unable to reconize the format from MultiGP.



   .. py:method:: _setup_raceclass_heats(raceclass_id, heat_data, heat_name = None)

      Setup heats for imported raceclass

      :param race_class: The raceclass to save to
      :param heats: The heat data from MultiGP
      :return: The last heat generated from the schedule



   .. py:method:: _setup_populated_rounds(selected_race, format_data, race_data)

      Setup a new raceclass with predefined heat data from MultiGP

      :param selected_race: The MultiGP race id
      :param format_id: The id of the format to set the class to.
      :param race_data: Downloaded MultiGP race data



   .. py:method:: _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

      :param race_data: The race schedule from MultiGP
      :return: The status of the check



   .. py:method:: import_class(selected_race, race_data)

      Setup a new raceclass within the RHUI based on the import MultiGP race(s).

      :param selected_race: The id of the MultiGP race
      :param race_data: The imported race data



   .. py:method:: zippyq(raceclass_id, selected_race, round_num)

      Imports a single ZippyQ round

      :param raceclass_id: The raceclass to import the ZippyQ round into
      :param selected_race: The MultiGP race to import the ZippyQ from
      :param round_num: The round number to pull from RaceSync
      :return: The import ZippyQ round as a Heat or None if failed
      to import.



   .. py:method:: manual_zippyq(_args = None)

      Used to manually trigger a ZippyQ import from the RHUI

      :param _args: Args passed from the event call, defaults to {}



   .. py:method:: auto_zippyq(args)

      Automatically import the next ZippyQ round into the same
      race class as the race that tiggered the import.

      :param args: Args passed from the event call, defaults to {}



