def _yield_movie_sub_stage_from_all_providers(self, query, full_path): """ Will yield MovieSubStages one provider at a time (like a generator). The function will proceed to the next provider if the current one failed to return a result. The return value is a two-dim array (each row contains result from one provider). """ reload_module(SubProviders) while setNextSubProvider(): _stages = QuerySubStage(getSubProvider().PROVIDER_NAME, query, full_path).getMovieSubStages() # Yield only if we got something. if _stages: yield _stages
def _get_movie_sub_stage_from_all_providers(self, query, full_path): """ Will return MovieSubStages all together (like a list). The return value is a two-dim array with a single row in it, a row that contains the results from all the providers. """ reload_module(SubProviders) # Two-dim array with single row. movie_sub_stages = [[]] while setNextSubProvider(): _stages = QuerySubStage( getSubProvider().PROVIDER_NAME, query, full_path).getMovieSubStages() # We might be getting empty list, so append is performed if it's # not empty. if _stages: movie_sub_stages[0].extend(_stages) return movie_sub_stages
def setNextSubProvider(): return_value = setNextSubProviderInModule() writeLog(INFO_LOGS.SETTING_PROVIDER % getSubProvider().PROVIDER_NAME) return return_value
def getSubProvider(): """ Call the getSubProvider function of the SubProviders module """ from SubProviders import getSubProvider return getSubProvider()