def get_help(self): if self.type in ["config", "menuconfig"]: config = data.get_config(self.value) text = self.value + ": " + config['title'] + "\n\n" if "help" in config: text += config['help'] else: text += "No help available" return text elif self.type in ["choice"]: choice = data.get_choice_group(self.value) text = choice['title'] + "\n\n" if "help" in choice: text += choice['help'] else: text += "No help available" return text elif self.type in ["menu"]: config = data.get_menu(self.value) if 'help' in config: return config['help'] return "No help available"
def menu_parse(): menus = {None: []} for i in data.get_menu_list(): menus[i] = [] menuconfig_stack = [] depends_stack = [] for (i_type, i_symbol) in data.iter_symbols_menuorder(): if i_type == "config": config = data.get_config(i_symbol) inmenu = config.get('inmenu') if 'title' not in config: # No title, so we don't display it continue while len(depends_stack) > 0: if expr.check_depends(config.get('depends'), depends_stack[-1]): break depends_stack.pop() while len(menuconfig_stack) > 0: if expr.check_depends(config.get('depends'), menuconfig_stack[-1]): inmenu = menuconfig_stack[-1] break menuconfig_stack.pop() depends_stack = [] if 'choice_group' in config: inmenu = config['choice_group'] config['depends_indent'] = len(depends_stack) menus[inmenu].append(MenuItem('config', i_symbol)) depends_stack.append(i_symbol) elif i_type == "menuconfig": config = data.get_config(i_symbol) inmenu = config.get('inmenu') while len(menuconfig_stack) > 0: if expr.check_depends(config.get('depends'), menuconfig_stack[-1]): inmenu = menuconfig_stack[-1] break menuconfig_stack.pop() menuconfig_stack.append(i_symbol) menus[i_symbol] = [] menus[inmenu].append(MenuItem('menuconfig', i_symbol)) elif i_type == "menu": menu = data.get_menu(i_symbol) inmenu = menu.get('inmenu') menuconfig_stack = [] menus[inmenu].append(MenuItem('menu', i_symbol)) elif i_type == "choice": inmenu = data.get_choice_group(i_symbol).get('inmenu') menus[i_symbol] = [] menus[inmenu].append(MenuItem('choice', i_symbol)) else: raise Exception("Unexpected menu item: type {}, symbol {}".format( i_type, i_symbol)) return menus