def METHOD_NAME(fn, new_lines):
    logger.info("updating %s", fn)
    with open(fn, "r") as f:
        lines = f.read().splitlines()
    istart, iend = [
        i
        for i, line in enumerate(lines)
        if re.match(r"\s*(#|\.\.)\s*autogenerated:\s+(start|end)", line)
    ]
    lines[istart + 1 : iend] = new_lines
    with open(fn, "w") as f:
        for line in lines:
            f.write(line + "\n")