def __init__(self, ploader, kwargs): del kwargs['settings_mixin'] self.plugin_list = [] temp_set = {} if 'settings' in kwargs: settings = get_settings(kwargs, kwargs['settings']) del kwargs['settings'] else: settings = kwargs if 'file_path' in settings: temp_set = self._import_yaml(kwargs['file_path'], 'plugins') del settings['file_path'] for key, val in temp_set.items(): settings[key] = get_settings(settings.get(key, {}), val) if 'plugins' in settings: self.plugin_list = settings['plugins'] del settings['plugins'] plugins = [] plugin_settings = {} for plugin in self.plugin_list: plugins.append(plugin[1]) plugin_settings[plugin[1]] = temp_set[plugin[0]] ploader.provides('PloaderFetch', PloaderFetch(plugins, plugin_settings))
def __init__(self, ploader, kwargs): settings = get_settings(kwargs.get('settings', {}), kwargs) plugin_list = settings.get('plugins', default_plugins) plugins = [] plugin_settings = {} for plugin in plugin_list: plugins.append(plugin[1]) plugin_settings[plugin[1]] = settings.get(plugin[0], {}) ploader.provides('PloaderFetch', PloaderFetch(plugins, plugin_settings))
def _import_yaml(self, path, obj): temp_set = {} data = yaml.load(open(path).read()) for key, plugin in data[obj].items(): if plugin[0] == 'yaml': for key, val in self._import_yaml(plugin[1], key).items(): temp_set[key] = get_settings(temp_set.get(key, {}), val) elif plugin[0] == 'python': for key, _ in self._import_python(plugin[1], key): temp_set[key] = data.get(key, {}) else: self._import_plugin(plugin[1], plugin[0], key) temp_set[key] = data.get(key, {}) return temp_set