<commit_before>from os.path import abspath, dirname
import argparse
import inspect
import logging

logger = logging.getLogger("pyfrc.sim")


class PyFrcSim:
    """
    Runs the robot using WPILib's GUI HAL Simulator
    """

    def __init__(self, parser: argparse.ArgumentParser):
        parser.add_argument(
            "--gui",
            default=False,
            action="store_true",
            help="Use the WPIlib simulation gui",
        )

    def run(self, options, robot_class, **static_options):

        if options.gui:
            try:
                import halsim_gui
            except ImportError:
                print("robotpy-halsim-gui is not installed!")
                exit(1)
            else:<commit_msg>always use gui if available<commit_after>from os.path import abspath, dirname
import argparse
import inspect
import logging
import importlib

logger = logging.getLogger("pyfrc.sim")


class PyFrcSim:
    """
    Runs the robot using WPILib's GUI HAL Simulator
    """

    def __init__(self, parser: argparse.ArgumentParser):
        parser.add_argument(
            "--gui",
            default=bool(importlib.util.find_spec("halsim_gui")),
            action="store_true",
            help="Use the WPIlib simulation gui",
        )

    def run(self, options, robot_class, **static_options):

        if options.gui:
            try:
                import halsim_gui
            except ImportError:
                print("robotpy-halsim-gui is not installed!")
                exit(1)
            else:
{'fraction_non_alphanumeric': 0.0907911802853437, 'fraction_numerical': 0.0012970168612191958, 'mean_word_length': 2.0433925049309667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4189966', 'n_tokens_mistral': 450, 'n_tokens_neox': 431, 'n_words': 113}