Renamed extractors module to services

This commit is contained in:
Manuel Cortez 2019-07-08 13:04:00 -05:00
parent eedf897de0
commit 084d3b8b10
8 changed files with 13 additions and 13 deletions

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
import config
from utils import get_extractors
from utils import get_services
from wxUI.configuration import configurationDialog
from . import player
@ -22,7 +22,7 @@ class configuration(object):
self.view.set_value("general", "output_device", i["name"])
break
self.view.realize()
extractors = get_extractors(import_all=True)
extractors = get_services(import_all=True)
for i in extractors:
if hasattr(i, "settings"):
panel = getattr(i, "settings")(self.view.notebook)

View File

@ -13,7 +13,7 @@ from pubsub import pub
from issueReporter import issueReporter
from wxUI import mainWindow, menus
from update import updater
from utils import get_extractors
from utils import get_services
from . import player, configuration
log = logging.getLogger("controller.main")
@ -26,7 +26,7 @@ class Controller(object):
# Setting up the player object
player.setup()
# Get main window
self.window = mainWindow.mainWindow(extractors=[i.interface.name for i in get_extractors()])
self.window = mainWindow.mainWindow(extractors=[i.interface.name for i in get_services()])
log.debug("Main window created")
self.window.change_status(_(u"Ready"))
# Here we will save results for searches as song objects.
@ -248,7 +248,7 @@ class Controller(object):
# real functions. These functions really are doing the work.
def search(self, text, extractor, *args, **kwargs):
extractors = get_extractors()
extractors = get_services()
for i in extractors:
if extractor == i.interface.name:
self.extractor = i.interface()
@ -266,6 +266,6 @@ class Controller(object):
wx.CallAfter(self.window.list.SetFocus)
def reload_extractors(self):
extractors = [i.interface.name for i in get_extractors()]
extractors = [i.interface.name for i in get_services()]
self.window.extractor.SetItems(extractors)
self.window.extractor.SetValue(extractors[0])

View File

@ -4,7 +4,7 @@ import requests
import threading
import logging
import types
import extractors
import services
from importlib import reload
from pubsub import pub
@ -73,15 +73,15 @@ def download_file(url, local_filename):
log.debug("Download finished successfully")
return local_filename
def get_extractors(import_all=False):
""" Function for importing everything wich is located in the extractors package and has a class named interface."""
def get_services(import_all=False):
""" Function for importing everything wich is located in the services package and has a class named interface."""
module_type = types.ModuleType
# first of all, import all classes for the package so we can reload everything if they have changes in config.
_classes = [m for m in extractors.__dict__.values() if type(m) == module_type and hasattr(m, 'interface')]
_classes = [m for m in services.__dict__.values() if type(m) == module_type and hasattr(m, 'interface')]
for cls in _classes:
reload(cls)
if not import_all:
classes = [m for m in extractors.__dict__.values() if type(m) == module_type and hasattr(m, 'interface') and m.interface.enabled != False]
classes = [m for m in services.__dict__.values() if type(m) == module_type and hasattr(m, 'interface') and m.interface.enabled != False]
else:
classes = [m for m in extractors.__dict__.values() if type(m) == module_type and hasattr(m, 'interface')]
return classes#sorted(classes, key=lambda c: c.name)
classes = [m for m in services.__dict__.values() if type(m) == module_type and hasattr(m, 'interface')]
return classes