INNER CODE UNIT · Python

append_line_to_section

fluxerapp/flutter_client · .github/scripts/append_release_direct_commits.py:234

def append_line_to_section(body: str, section_heading: str, line: str) -> str:
    if line in body:
        return body
    section_pattern = re.compile(
        rf"({re.escape(section_heading)}\n)(.*?)(?=\n#+[A-Z]|\Z)",
        re.DOTALL,
    )
    match = section_pattern.search(body)
    if match is not None:
        section_content = match.group(2).rstrip()
        replacement = f"{match.group(1)}{section_content}\n{line}\n"
        return body[: match.start()] + replacement + body[match.end() :]
    insert_at = find_section_insert_at(body, section_heading)
    block = f"\n{section_heading}\n{line}\n"
    return body[:insert_at] + block + body[insert_at:]


def reorder_change_sections(body: str) -> str:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…