-
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(extensions): start building an interface to split notifiers, pro…
…viders, metadata, clients, etc out into namespaced plugin packages Signed-off-by: miigotu <[email protected]>
- Loading branch information
Showing
3 changed files
with
51 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import importlib | ||
import pkgutil | ||
|
||
from sickchill import logger, settings | ||
from sickchill.oldbeard import config | ||
|
||
import sickchill.extensions | ||
|
||
|
||
def iter_namespace(ns_pkg): | ||
return pkgutil.iter_modules(ns_pkg.__path__, ns_pkg.__name__ + ".") | ||
|
||
|
||
def discover(): | ||
global extenstions | ||
extensions = {} | ||
for finder, name, ispkg in iter_namespace(sickchill.extensions): | ||
if name == __name__: | ||
continue | ||
try: | ||
plugin = importlib.import_module(name) | ||
extensions[name] = plugin | ||
except Exception as e: | ||
logger.debug("Error importing extension: {0}".format(name), exc_info=e) | ||
|
||
config.check_section(settings.CFG, "extensions") | ||
for extension in extensions: | ||
logger.debug("Loading {extension} from {path}".format(extension=extension, path=extensions[extension].__path__)) | ||
config.check_section(settings.CFG["extensions"], extension.name) | ||
|
||
global clients, providers, metadata, notifiers, indexers, post_processors | ||
|
||
# Clients | ||
clients = {extension.name: extension for name, extension in extensions.items() if hasattr(extension, "Client")} | ||
|
||
# Providers | ||
providers = {extension.name: extension for name, extension in extensions.items() if hasattr(extension, "Provider")} | ||
|
||
# Metadata | ||
metadata = {extension.name: extension for name, extension in extensions.items() if hasattr(extension, "Metadata")} | ||
|
||
# Notifiers | ||
notifiers = {extension.name: extension for name, extension in extensions.items() if hasattr(extension, "Notifier")} | ||
|
||
# TVDB, TVMAZE, TMDB, etc | ||
indexers = {extension.name: extension for name, extension in extensions.items() if hasattr(extension, "Indexer")} | ||
|
||
# Post Processors | ||
post_processors = {extension.name: extension for name, extension in extensions.items() if hasattr(extension, "PostProcessor")} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters