MCPcopy Create free account
hub / github.com/apache/fory / parse_sync_mappings

Function parse_sync_mappings

ci/validate_fory_site_sync.py:31–63  ·  view source on GitHub ↗
(sync_file: pathlib.Path)

Source from the content-addressed store, hash-verified

29
30
31def 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
66def to_workspace_path(root: pathlib.Path, relative_path: str) -> pathlib.Path:

Callers 1

sync_filesFunction · 0.85

Calls 2

matchMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected