Пример #1
0
def write_config(config_filename):
    enforce_dependent_values()
    with utils.open_and_write_if_changed(config_filename) as f:
        for (i_type, i_symbol) in data.iter_symbols_menuorder():
            if i_type in ["config", "menuconfig"]:
                c = data.get_config(i_symbol)
                mark_set_by_user = "******"
                if not can_enable(c):
                    # Don't output this option because it cannot be enabled
                    continue
                elif c['datatype'] == "bool":
                    if c['value'] is True:
                        f.write("CONFIG_%s=y" % i_symbol)
                    else:
                        f.write("# CONFIG_%s is not set" % i_symbol)
                        mark_set_by_user = "******"
                elif c['datatype'] == "string":
                    quoted_str = re.sub(r'(["\\])', r'\\\1', c['value'])
                    f.write('CONFIG_%s="%s"' % (i_symbol, quoted_str))
                else:
                    f.write("CONFIG_%s=%s" % (i_symbol, c['value']))
                # Save meta data as user explicit mark this
                if c['is_user_set']:
                    f.write("%s" % mark_set_by_user)
                f.write("\n")
            elif i_type == "menu":
                f.write("\n#\n# %s\n#\n" % data.get_menu_title(i_symbol))
    logger.info("Written configuration to '%s'" % config_filename)
Пример #2
0
def get_user_set_options():
    """
    Return all the options which have been set by the user
    """
    user_set_options = []
    for (i_type, i_symbol) in data.iter_symbols_menuorder():
        if i_type in ["config", "menuconfig"]:
            c = data.get_config(i_symbol)
            if c['is_user_set']:
                value = c['value']
                if c['datatype'] == "bool":
                    value = "y" if c['value'] else "n"
                source = c['source'] if "source" in c else ""
                user_set_options.append((i_symbol, value, source))
    return user_set_options
Пример #3
0
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