MCPcopy Create free account
hub / github.com/VectifyAI/OpenKB / _remove_section_entry

Function _remove_section_entry

openkb/agent/compiler.py:896–915  ·  view source on GitHub ↗

Remove the first entry whose line starts with ``- {link}`` in the named section. Returns True if an entry was removed. Matching is intentionally strict (prefix-only, matching the canonical bullet form written by ``_insert_section_entry`` and friends). An earlier substring fallback c

(lines: list[str], heading: str, link: str)

Source from the content-addressed store, hash-verified

894
895
896def _remove_section_entry(lines: list[str], heading: str, link: str) -> bool:
897 """Remove the first entry whose line starts with ``- {link}`` in the named
898 section. Returns True if an entry was removed.
899
900 Matching is intentionally strict (prefix-only, matching the canonical
901 bullet form written by ``_insert_section_entry`` and friends). An earlier
902 substring fallback could wrongly delete sibling bullets whose brief text
903 referenced the removed link.
904 """
905 bounds = _get_section_bounds(lines, heading)
906 if bounds is None:
907 return False
908
909 start, end = bounds
910 entry_prefix = f"- {link}"
911 for i in range(start, end):
912 if lines[i].startswith(entry_prefix):
913 del lines[i]
914 return True
915 return False
916
917
918def _write_summary(

Calls 1

_get_section_boundsFunction · 0.85