def __getitem__(self, key): try: return dict.__getitem__(self, key) except IndexError: raise hf.ConfigError( "Required parameter '{0}' not specified".format(key)) except KeyError: raise hf.ConfigError( "Required parameter '{0}' not specified".format(key))
def createCategoryObjects(): ''' Generates the category objects from the happyface configuration :return: :rtype: ''' category_list = [] used_modules = [] category_names = hf.category.config.sections() if len(hf.config.get('happyface', 'categories')) > 0: category_names = hf.config.get('happyface', 'categories').split(',') for category in category_names: conf = hf.configtools.ConfigDict(hf.category.config.items(category)) module_conf = {} for module in conf["modules"].split(","): try: if len(module) == 0: continue if module in used_modules: raise hf.ConfigError( "Module '%s' used second time in category '%s'" % (module, category)) module_conf[module] = hf.configtools.ConfigDict( hf.module.config.items(module)) used_modules.append(module) except NoSectionError, e: msg = "Tried to use module '%s' in category '%s', but it was never mentioned in module configuration" raise hf.exceptions.ConfigError(msg % (module, category)) category_list.append( hf.category.CategoryProxy(category, conf, module_conf))
def getModuleClass(mod_name): """ Get the module class for a given module name. :param mod_name: Name of the module :ptype mod_name: string """ if mod_name not in __module_class_list: raise hf.ConfigError("Module class {0} not found".format(mod_name)) return __module_class_list[mod_name]
def __init__(self, download_command): try: self.download_command = download_command self.config_source, self.options, self.url = download_command.split("|") self.config_source = self.config_source.lower() if self.config_source == "global": self.options = "" self.tried_download = False except ValueError: raise hf.ConfigError("Download command string malformed") self.is_downloaded = False self.error = "" self.file_path = "" self.file_url = "" self.keep_tmp = False self.is_archived = False