def avail_easyconfig_params(easyblock, output_format): """ Compose overview of available easyconfig parameters, in specified format. """ params = copy.deepcopy(DEFAULT_CONFIG) # include list of extra parameters (if any) extra_params = {} app = get_easyblock_class(easyblock, default_fallback=False) if app is not None: extra_params = app.extra_options() params.update(extra_params) # compose title title = "Available easyconfig parameters" if extra_params: title += " (* indicates specific to the %s easyblock)" % app.__name__ # group parameters by category grouped_params = OrderedDict() for category in sorted_categories(): # exclude hidden parameters if category[1].upper() in [HIDDEN]: continue grpname = category[1] grouped_params[grpname] = {} for name, (dflt, descr, cat) in params.items(): if cat == category: if name in extra_params: # mark easyblock-specific parameters name = '%s*' % name grouped_params[grpname].update({name: (descr, dflt)}) if not grouped_params[grpname]: del grouped_params[grpname] # compose output, according to specified format (txt, rst, ...) avail_easyconfig_params_functions = { FORMAT_RST: avail_easyconfig_params_rst, FORMAT_TXT: avail_easyconfig_params_txt, } return avail_easyconfig_params_functions[output_format](title, grouped_params)
def avail_easyconfig_params(easyblock, output_format): """ Compose overview of available easyconfig parameters, in specified format. """ params = copy.deepcopy(DEFAULT_CONFIG) # include list of extra parameters (if any) extra_params = {} app = get_easyblock_class(easyblock, default_fallback=False) if app is not None: extra_params = app.extra_options() params.update(extra_params) # compose title title = "Available easyconfig parameters" if extra_params: title += " (* indicates specific to the %s easyblock)" % app.__name__ # group parameters by category grouped_params = OrderedDict() for category in sorted_categories(): # exclude hidden parameters if category[1].upper() in [HIDDEN]: continue grpname = category[1] grouped_params[grpname] = {} for name, (dflt, descr, cat) in params.items(): if cat == category: if name in extra_params: # mark easyblock-specific parameters name = '%s*' % name grouped_params[grpname].update({name: (descr, dflt)}) if not grouped_params[grpname]: del grouped_params[grpname] # compose output, according to specified format (txt, rst, ...) avail_easyconfig_params_functions = { FORMAT_RST: avail_easyconfig_params_rst, FORMAT_TXT: avail_easyconfig_params_txt, } return avail_easyconfig_params_functions[output_format](title, grouped_params)