def _load_authnz_wrapper(self): authnz_wrapper_class_name = self.config.get('AUTHNZ_WRAPPER', None) if authnz_wrapper_class_name: authnz_wrapper_list = load_classes(default=[authnz_wrapper_class_name]) if isinstance(authnz_wrapper_list, list) and len(authnz_wrapper_list) == 1: return authnz_wrapper_list.pop() return None
def load_authnz_wrapper(self): authnz_wrapper_class_name = self.config.get('AUTHNZ_WRAPPER', None) if authnz_wrapper_class_name: authnz_wrapper_list = load_classes( default=[authnz_wrapper_class_name]) if isinstance(authnz_wrapper_list, list) and len(authnz_wrapper_list) == 1: return authnz_wrapper_list.pop() return None
def new_instance(cls, config): authnz_wrapper_list = load_classes(default=[config.AUTHNZ_WRAPPER]) if isinstance(authnz_wrapper_list, list) and len(authnz_wrapper_list) == 1: authnz_wrapper_class = authnz_wrapper_list.pop() else: raise Exception('An authentication/authorization wrapper must be defined!') authnz_wrapper = authnz_wrapper_class(config) return AuthNZElasticSearchProvider( config=config, authnz_wrapper=authnz_wrapper )
def new_instance(cls, config): authnz_wrapper_list = load_classes(default=[config.AUTHNZ_WRAPPER]) if isinstance(authnz_wrapper_list, list) and len(authnz_wrapper_list) == 1: authnz_wrapper_class = authnz_wrapper_list.pop() else: raise Exception( 'An authentication/authorization wrapper must be defined!') authnz_wrapper = authnz_wrapper_class(config) return AuthNZElasticSearchProvider(config=config, authnz_wrapper=authnz_wrapper)
def test_can_load_classes(self): from holmes.models.domain import Domain from holmes.models.page import Page from holmes.models.review import Review classes = load_classes(default=[ 'holmes.models.domain.Domain', 'holmes.models.page.Page', 'holmes.models.review.Review', ]) expect(classes).to_length(3) expect(classes[0]).to_equal(Domain) expect(classes[1]).to_equal(Page) expect(classes[2]).to_equal(Review)
def main(): parser = SearchProvider.argparser() args = parser.parse_args() try: config = Config() if args.conf: config = config.load(args.conf[0]) search_providers = load_classes(default=[config['SEARCH_PROVIDER']]) if isinstance(search_providers, list) and len(search_providers) == 1: search_provider = search_providers.pop() search_provider.main() else: logging.error('Could not instantiate search provider!') sys.exit(1) except ConfigurationError: logging.error('Could not load config! Use --conf conf_file') sys.exit(1) except KeyError: logging.error('Could not parse config! Check it\'s contents') sys.exit(1)
def _load_facters(self): return load_classes(default=self.config.FACTERS)
def _load_validators(self): return load_classes(default=self.config.VALIDATORS)
def load_search_provider(self): search_provider = load_classes(default=[self.config.SEARCH_PROVIDER]) if isinstance(search_provider, list) and len(search_provider) == 1: return search_provider.pop() else: raise Exception('A search provider must be defined!')
def load_error_handlers(self): return load_classes(default=self.config.ERROR_HANDLERS)
def _load_search_provider(self): search_provider = load_classes(default=[self.config.SEARCH_PROVIDER]) if isinstance(search_provider, list) and len(search_provider) == 1: return search_provider.pop() else: raise Exception('A search provider must be defined!')