def test_imports_and_class_names_in_modules(self): """ Checking that all the class names and modules listed in the APIData and Player structures exist. This is only done with the APIs supported by the current operating system though, so for a full coverage this test should be done on all supported platforms. """ # The API has 2 different functions, one to obtain the APIData entry # (get_api_data), and another to initialize the API (initialize_api). # Both are tested this way. for api in APIData: if CURRENT_PLATFORM in api.platforms: win.initialize_api(get_api_data(api.name)) for player in PlayerData: initialize_player(player.name, config) # Also checking that AttributeError is raised when an unexisting # player is provided. with self.assertRaises(AttributeError): initialize_player('player-does-not-exist', config) # If the API isn't found, KeyError should be raised. with self.assertRaises(KeyError): get_api_data('api-does-not-exist')
def test_imports_and_class_names_in_modules(self): """ Checking that all the class names and modules listed in the APIData and Player structures exist. This is only done with the APIs supported by the current operating system though, so for a full coverage this test should be done on all supported platforms and with all the optional dependencies installed. """ for api in APIS: if api.compatible and api.installed: win.initialize_api(api) for player in PLAYERS: if player.compatible and player.installed: initialize_player(player, config)
def __init__(self, config: Config) -> None: """ Main window with the GUI and whatever player is being used. """ super().__init__() self.setWindowTitle('vidify') # Setting the window to stay on top if config.stay_on_top: self.setWindowFlags(Qt.WindowStaysOnTopHint) # Setting the fullscreen and window size if config.fullscreen: self.showFullScreen() else: self.resize(config.width or 800, config.height or 600) self.layout = QHBoxLayout(self) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) # Loading the used fonts (Inter) font_db = QFontDatabase() for font in Res.fonts: font_db.addApplicationFont(font) # Initializing the player and saving the config object in the window. self.player = initialize_player(config.player, config) logging.info("Using %s as the player", config.player) self.config = config # The audiosync feature is optional until it's more stable. if self.config.audiosync: from vidify.audiosync import AudiosyncWorker self.audiosync = AudiosyncWorker() else: self.audiosync = None # The API initialization is more complex. For more details, please # check the flow diagram in vidify.api. First we have to check if # the API is saved in the config: try: api_data = get_api_data(config.api) except KeyError: # Otherwise, the user is prompted for an API. After choosing one, # it will be initialized from outside this function. logging.info("API not found: prompting the user") self.API_selection = APISelection() self.layout.addWidget(self.API_selection) self.API_selection.api_chosen.connect(self.on_api_selection) else: logging.info("Using %s as the API", config.api) self.initialize_api(api_data)
def on_setup_done(self, api: APIData, player: PlayerData) -> None: """ Method called when the API and Player are selected with APISelection. """ # Completely removing the widget used to obtain the API string self.layout.removeWidget(self.setup_widget) self.setup_widget.setParent(None) self.setup_widget.hide() del self.setup_widget # Saving the API and Player in the config self.config.api = api.id self.config.player = player.id # Starting the asynchronous API initialization self.initialize_api(api) logging.info("Using %s as the API", api.id) # Initializing the player self.player = initialize_player(player, self.config) logging.info("Using %s as the player", player.id)