Showing
1 changed file
with
19 additions
and
2 deletions
| @@ -376,14 +376,31 @@ class GraphStorage: | @@ -376,14 +376,31 @@ class GraphStorage: | ||
| 376 | chapters_dir = self.chapters_dir | 376 | chapters_dir = self.chapters_dir |
| 377 | if not chapters_dir.exists(): | 377 | if not chapters_dir.exists(): |
| 378 | return None | 378 | return None |
| 379 | + | ||
| 380 | + # 兼容不同分隔符(report-xxx 与 report_xxx)以及简化匹配 | ||
| 381 | + if not report_id: | ||
| 382 | + return None | ||
| 383 | + normalized_target = re.sub(r'[-_]', '', str(report_id)).lower() | ||
| 384 | + alt_targets = { | ||
| 385 | + report_id, | ||
| 386 | + str(report_id).replace('_', '-'), | ||
| 387 | + str(report_id).replace('-', '_'), | ||
| 388 | + normalized_target, | ||
| 389 | + } | ||
| 379 | 390 | ||
| 380 | # 查找匹配报告ID的目录 | 391 | # 查找匹配报告ID的目录 |
| 381 | for run_dir in chapters_dir.iterdir(): | 392 | for run_dir in chapters_dir.iterdir(): |
| 382 | if not run_dir.is_dir(): | 393 | if not run_dir.is_dir(): |
| 383 | continue | 394 | continue |
| 384 | 395 | ||
| 385 | - # 检查目录名是否包含报告ID | ||
| 386 | - if report_id in run_dir.name: | 396 | + name = run_dir.name |
| 397 | + normalized_name = re.sub(r'[-_]', '', name).lower() | ||
| 398 | + | ||
| 399 | + # 检查目录名是否包含报告ID或归一化后相等 | ||
| 400 | + if ( | ||
| 401 | + any(t for t in alt_targets if t and t in name) | ||
| 402 | + or normalized_name == normalized_target | ||
| 403 | + ): | ||
| 387 | graph_path = run_dir / self.FILENAME | 404 | graph_path = run_dir / self.FILENAME |
| 388 | if graph_path.exists(): | 405 | if graph_path.exists(): |
| 389 | return graph_path | 406 | return graph_path |
-
Please register or login to post a comment