Returns a dictionary of dmidecode information parsed from a dmidecode list
    (i.e. from context.content)

    This method will attempt to handle leading spaces rather than tabs.

def parse_dmidecode(dmidecode_content, pythonic_keys=False):
    """
    Returns a dictionary of dmidecode information parsed from a dmidecode list
    (i.e. from context.content)

    This method will attempt to handle leading spaces rather than tabs.
    """
    if len(dmidecode_content) < 3:
        return {}

    section = None
    obj = {}
    current = {}

    buf = "\n".join(dmidecode_content).strip()

    # Some versions of DMIDecode have an extra
    # level of indentation, as well as slightly
    # different configuration for each section.
    if "\tDMI type" in buf:
        pat = re.compile("^\t", flags=re.MULTILINE)
        buf = pat.sub("", buf)

        buf = buf.replace("\nDMI type", "DMI type")
        buf = buf.replace("\nHandle", "\n\nHandle")

    buf = buf.replace("\n\t\t", "\t")

    def fix_key(k):
        return k.lower().replace(" ", "_") if pythonic_keys else k

    for line in buf.splitlines():
        nbline = line.strip()
        if section:
            if not nbline:
                # There maybe some sections with the same name, such as:
                # processor_information
                if section in obj:
                    obj[section].append(current)
                else:
                    obj[section] = [current]
                current = {}
                section = key = None
                continue

            elif line.startswith("\t"):
                if ":" in line:
                    key, value = nbline.split(":", 1)
                    key = fix_key(key)
                    value = value.strip()

                if "\t" in value:
                    current[key] = list(filter(None, value.split("\t")))
                else:
                    current[key] = value
            else:
                section = None

        if not section:
            # Ignore 'Table at 0xBFFCB000' and similar.
            if not ('Table' in nbline or 'table' in nbline):
                section = fix_key(nbline)

    if section in obj:
        obj[section].append(current)
    else:
        obj[section] = [current]

    return obj