def parse_fragment(
    filename: str, strip_path_prefix: str = None
) -> dict[str, OptionValue]:
    """
    Parse Buildroot Kconfig fragment and return dict of OptionValue objects.
    """
    options: dict[str, OptionValue] = {}

    with open(filename) as f:
        if strip_path_prefix and filename.startswith(strip_path_prefix):
            filename = filename[len(strip_path_prefix) :]

        for line_number, line in enumerate(f, 1):
            if matches := re.match(regex, line):
                if matches["option_unset"]:
                    value = OptionValue(
                        matches["option_unset"], None, filename, line_number
                    )
                    options.update({matches.group("option_unset"): value})
                else:
                    value = OptionValue(
                        matches["option_set"], matches["value"], filename, line_number
                    )
                    options.update({matches.group("option_set"): value})

    return options

    Parse Buildroot Kconfig fragment and return dict of OptionValue objects.
    
buildroot-external/scripts/check-dotconfig.py