在 Codespace 中打开文件并提交到 LeetCode 评测(不执行 push) Args: filename: 要评测的文件名 Returns: 评测结果字典
(self, filename: str)
| 546 | return False |
| 547 | |
| 548 | async def eval_single_file(self, filename: str) -> Dict[str, Any]: |
| 549 | """ |
| 550 | 在 Codespace 中打开文件并提交到 LeetCode 评测(不执行 push) |
| 551 | |
| 552 | Args: |
| 553 | filename: 要评测的文件名 |
| 554 | |
| 555 | Returns: |
| 556 | 评测结果字典 |
| 557 | """ |
| 558 | logger.info(f"| 🔍 Evaluating: {filename}") |
| 559 | |
| 560 | # 0. Check if Codespace sync is needed (from previous batch_push with sync_codespace=False) |
| 561 | # This is safe here because the caller should hold submit_lock |
| 562 | if self._needs_sync: |
| 563 | logger.info("| 🔄 Performing pending Codespace sync before evaluation...") |
| 564 | await self._sync_codespace_repo() |
| 565 | self._needs_sync = False |
| 566 | |
| 567 | # 1. Open file in Codespace |
| 568 | await self._open_editor_file(filename) |
| 569 | await asyncio.sleep(2) |
| 570 | |
| 571 | # 2. Trigger LeetCode submission |
| 572 | logger.info("| 🔍 Triggering LeetCode submission...") |
| 573 | await self.page.keyboard.press("Meta+Shift+P") |
| 574 | #await self.page.keyboard.press("Control+Shift+P") |
| 575 | await asyncio.sleep(1) |
| 576 | await self.page.keyboard.type("LeetCode: Submit to LeetCode") |
| 577 | await asyncio.sleep(1) |
| 578 | await self.page.keyboard.press("Enter") |
| 579 | await asyncio.sleep(5) |
| 580 | |
| 581 | # 3. Wait for result |
| 582 | result = await self._wait_for_result() |
| 583 | |
| 584 | # 4. Close editors (使用安全方法,失败也不影响结果) |
| 585 | await self._safe_close_all_editors() |
| 586 | |
| 587 | return result |
| 588 | |
| 589 | # ==================== 原有的单个提交方法(保留兼容性) ==================== |
| 590 |
no test coverage detected