Delete a chapter and its content.
(
title: Annotated[str, ParamMeta(description="Chapter title to delete (supports multi-level index e.g. 'Intro/Background')")],
_context: Dict[str, Any] | None = None,
)
| 509 | |
| 510 | |
| 511 | def report_del_chapter( |
| 512 | title: Annotated[str, ParamMeta(description="Chapter title to delete (supports multi-level index e.g. 'Intro/Background')")], |
| 513 | _context: Dict[str, Any] | None = None, |
| 514 | ) -> str: |
| 515 | """ |
| 516 | Delete a chapter and its content. |
| 517 | """ |
| 518 | ctx = FileToolContext(_context) |
| 519 | _, report_file = _get_files(ctx) |
| 520 | _, report_lock = _get_locks(ctx) |
| 521 | |
| 522 | with FileLock(report_lock): |
| 523 | lines = _read_report_lines(report_file) |
| 524 | |
| 525 | start, end = _find_chapter_range(lines, title) |
| 526 | if start == -1: |
| 527 | return f"Chapter '{title}' not found." |
| 528 | |
| 529 | del lines[start:end] |
| 530 | |
| 531 | _save_report(report_file, lines) |
| 532 | return f"Deleted chapter '{title}'" |
| 533 | |
| 534 | def report_export_pdf( |
| 535 | _context: Dict[str, Any] | None = None, |
nothing calls this directly
no test coverage detected