-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
3 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
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,36 @@ | ||
# Copyright (c) conda-store development team. All rights reserved. | ||
# Use of this source code is governed by a BSD-style | ||
# license that can be found in the LICENSE file. | ||
|
||
from conda_store_server.plugins import BUILTIN_PLUGINS | ||
|
||
|
||
class PluginRegistry(): | ||
_instance = None | ||
|
||
def __new__(cls): | ||
if cls._instance is None: | ||
cls._instance = super(PluginRegistry, cls).__new__(cls) | ||
return cls._instance | ||
|
||
def __init__(self): | ||
# plugins are registered in the map of the form: | ||
# {plugin_name: plugin_class} | ||
self.registered = {} | ||
|
||
def list_plugin_names(self): | ||
return self.registered.keys() | ||
|
||
def get_plugin(self, name): | ||
return self.registered.get(name) | ||
|
||
def register_plugin(self, p): | ||
"""Adds plugin to the list of registered plugins""" | ||
plugin_name = p.name() | ||
if plugin_name not in self.registered: | ||
self.registered[plugin_name] = p | ||
|
||
def collect_plugins(self): | ||
"""Registers all availble plugins with the plugin registry""" | ||
for plugin in BUILTIN_PLUGINS: | ||
self.register_plugin(plugin) |