Extract the specific section for a file from the summary content Args: summary_content: Full summary content target_file_path: Path of the target file Returns: File-specific section or None if not found
(
summary_content: str, target_file_path: str
)
| 984 | |
| 985 | |
| 986 | def _extract_file_section_from_summary( |
| 987 | summary_content: str, target_file_path: str |
| 988 | ) -> str: |
| 989 | """ |
| 990 | Extract the specific section for a file from the summary content |
| 991 | |
| 992 | Args: |
| 993 | summary_content: Full summary content |
| 994 | target_file_path: Path of the target file |
| 995 | |
| 996 | Returns: |
| 997 | File-specific section or None if not found |
| 998 | """ |
| 999 | import re |
| 1000 | |
| 1001 | # Normalize the target path for comparison |
| 1002 | normalized_target = _normalize_file_path(target_file_path) |
| 1003 | |
| 1004 | # Pattern to match implementation sections with separator lines |
| 1005 | section_pattern = r"={80}\s*\n## IMPLEMENTATION File ([^;]+); ROUND \d+\s*\n={80}(.*?)(?=\n={80}|\Z)" |
| 1006 | |
| 1007 | matches = re.findall(section_pattern, summary_content, re.DOTALL) |
| 1008 | |
| 1009 | for file_path_in_summary, section_content in matches: |
| 1010 | file_path_in_summary = file_path_in_summary.strip() |
| 1011 | section_content = section_content.strip() |
| 1012 | |
| 1013 | # Normalize the path from summary for comparison |
| 1014 | normalized_summary_path = _normalize_file_path(file_path_in_summary) |
| 1015 | |
| 1016 | # Check if paths match using multiple strategies |
| 1017 | if _paths_match( |
| 1018 | normalized_target, |
| 1019 | normalized_summary_path, |
| 1020 | target_file_path, |
| 1021 | file_path_in_summary, |
| 1022 | ): |
| 1023 | # Return the complete section with proper formatting |
| 1024 | file_section = f"""================================================================================ |
| 1025 | ## IMPLEMENTATION File {file_path_in_summary}; ROUND [X] |
| 1026 | ================================================================================ |
| 1027 | |
| 1028 | {section_content} |
| 1029 | |
| 1030 | --- |
| 1031 | *Extracted from implement_code_summary.md*""" |
| 1032 | return file_section |
| 1033 | |
| 1034 | # If no section-based match, try alternative parsing method |
| 1035 | return _extract_file_section_alternative(summary_content, target_file_path) |
| 1036 | |
| 1037 | |
| 1038 | def _normalize_file_path(file_path: str) -> str: |
no test coverage detected