(sync_file: pathlib.Path)
| 29 | |
| 30 | |
| 31 | def parse_sync_mappings(sync_file: pathlib.Path) -> List[Tuple[str, str]]: |
| 32 | mappings: List[Tuple[str, str]] = [] |
| 33 | source = None |
| 34 | current_target = None |
| 35 | for raw in sync_file.read_text(encoding="utf-8").splitlines(): |
| 36 | no_comment = raw.split("#", 1)[0].rstrip() |
| 37 | if not no_comment.strip(): |
| 38 | continue |
| 39 | |
| 40 | top_level = re.match(r"^([^\s][^:]*):\s*$", no_comment) |
| 41 | if top_level: |
| 42 | current_target = top_level.group(1).strip() |
| 43 | source = None |
| 44 | continue |
| 45 | |
| 46 | if current_target != TARGET_REPO: |
| 47 | continue |
| 48 | |
| 49 | stripped = no_comment.strip() |
| 50 | source_match = re.match(r"^-\s*source:\s*(.+)$", stripped) |
| 51 | if source_match: |
| 52 | source = source_match.group(1).strip().strip("'\"") |
| 53 | continue |
| 54 | |
| 55 | dest_match = re.match(r"^dest:\s*(.+)$", stripped) |
| 56 | if dest_match and source: |
| 57 | dest = dest_match.group(1).strip().strip("'\"") |
| 58 | mappings.append((source, dest)) |
| 59 | source = None |
| 60 | |
| 61 | if not mappings: |
| 62 | raise RuntimeError(f"no sync mappings found for {TARGET_REPO} in {sync_file}") |
| 63 | return mappings |
| 64 | |
| 65 | |
| 66 | def to_workspace_path(root: pathlib.Path, relative_path: str) -> pathlib.Path: |
no test coverage detected