Replace the first matching entry within a specific section.
(lines: list[str], heading: str, link: str, entry: str)
| 868 | |
| 869 | |
| 870 | def _replace_section_entry(lines: list[str], heading: str, link: str, entry: str) -> bool: |
| 871 | """Replace the first matching entry within a specific section.""" |
| 872 | bounds = _get_section_bounds(lines, heading) |
| 873 | if bounds is None: |
| 874 | return False |
| 875 | |
| 876 | start, end = bounds |
| 877 | entry_prefix = f"- {link}" |
| 878 | for i in range(start, end): |
| 879 | if lines[i].startswith(entry_prefix): |
| 880 | lines[i] = entry |
| 881 | return True |
| 882 | return False |
| 883 | |
| 884 | |
| 885 | def _insert_section_entry(lines: list[str], heading: str, entry: str) -> bool: |
no test coverage detected