Extract all grid position information from the code
(self, code: str)
| 691 | ] |
| 692 | |
| 693 | def extract_grid_positions(self, code: str) -> List[GridPosition]: |
| 694 | """Extract all grid position information from the code""" |
| 695 | positions = [] |
| 696 | lines = code.split("\n") |
| 697 | |
| 698 | for line_num, line in enumerate(lines, 1): |
| 699 | # Check place_at_grid |
| 700 | match = re.search(self.grid_patterns[0], line) |
| 701 | if match: |
| 702 | obj_name = match.group(1).strip() |
| 703 | grid_pos = match.group(2) |
| 704 | scale = float(match.group(3)) if match.group(3) else None |
| 705 | |
| 706 | positions.append( |
| 707 | GridPosition( |
| 708 | object_name=obj_name, |
| 709 | method="place_at_grid", |
| 710 | position=grid_pos, |
| 711 | scale_factor=scale, |
| 712 | line_number=line_num, |
| 713 | original_code=line.strip(), |
| 714 | ) |
| 715 | ) |
| 716 | |
| 717 | # Check place_in_area |
| 718 | match = re.search(self.grid_patterns[1], line) |
| 719 | if match: |
| 720 | obj_name = match.group(1).strip() |
| 721 | start_pos = match.group(2) |
| 722 | end_pos = match.group(3) |
| 723 | scale = float(match.group(4)) if match.group(4) else None |
| 724 | |
| 725 | positions.append( |
| 726 | GridPosition( |
| 727 | object_name=obj_name, |
| 728 | method="place_in_area", |
| 729 | position=f"{start_pos}-{end_pos}", |
| 730 | scale_factor=scale, |
| 731 | line_number=line_num, |
| 732 | original_code=line.strip(), |
| 733 | ) |
| 734 | ) |
| 735 | |
| 736 | return positions |
| 737 | |
| 738 | def generate_position_table(self, positions: List[GridPosition]) -> str: |
| 739 | """Generate a position table for MLLM analysis""" |
no test coverage detected