def parse(config_fileobj, section): """ Takes in a file-like object """ parser = SafeConfigParser() parser.readfp(config_fileobj) cfg = create_dict(parser, section) logging.info(pretty_print(cfg)) return cfg
def __get_available_components(self): """ """ components_dir = self.builder_params.get('components_dir') config_filepath = util_methods.locate_config(components_dir) # get the plugin parameters-- i.e. each component needs to have a script and entry method to call. plugin_parameters = cfg_parser.read_config(config_filepath, 'plugin_params') self.builder_params.add(plugin_parameters) entry_module = plugin_parameters[ 'entry_module'] #the script filename (minus the .py extension) entry_method = plugin_parameters['entry_method'] logging.info( "Search for available components with configuration file at: %s", config_filepath) available_components = cfg_parser.read_config(config_filepath, 'plugins') # the paths in the dictionary above are relative to the components_dir-- prepend that directory name for the full path available_components = { k: os.path.join(components_dir, available_components[k]) for k in available_components.keys() } # check that the plugin components have the required structure self.available_components = {} for k in available_components.keys(): if util_methods.component_structure_valid(available_components[k], entry_module, entry_method): self.available_components[k] = available_components[k] logging.info('Available components: ') logging.info(pretty_print(self.available_components)) # get the specifications for the standard components and the analysis components self.standard_components = [ c for c in cfg_parser.read_config(config_filepath, 'standard_plugins').values()[0] if c in self.available_components.keys() ] self.analysis_components = [ c for c in cfg_parser.read_config(config_filepath, 'analysis_plugins').values()[0] if c in self.available_components.keys() ] logging.info('Standard components: %s', self.standard_components) logging.info('Analysis components: %s', self.analysis_components)
def __str__(self): return pretty_print(self.__param_dict__)