def extract(line, comment=""):
    """
    Return a key/value pair from a string. This will most likely be a line in a
    ParameterSet file. It also returns (optionally) a documentation string from
    lines beginning with '##'.
    """
    line = line.lstrip()
    line = line.strip("\n")
    if len(line) == 0:
        return None, comment
    elif line.startswith("#"):
        if line.startswith("##"):
            if len(comment):
                line = line.strip("#")
                if len(line) and line.startswith(" "):
                    line = line[1:]
                return None, "\n".join((comment, line))
            else:
                line = line.strip("#")
                if len(line) and line.startswith(" "):
                    line = line[1:]
                return None, line
        return None, comment
    else:
        line = line.strip()
        kv = line.split("=", 1)
        return [i.strip() for i in kv], comment