MCPcopy Create free account
hub / github.com/instantdb/instant / main

Function main

client/packages/python/scripts/run_unasync.py:92–124  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

90
91
92def main() -> None:
93 sync_dir = SRC / "_sync"
94 if sync_dir.exists():
95 shutil.rmtree(sync_dir)
96
97 async_files = discover_async_files()
98
99 with tempfile.TemporaryDirectory() as tmpdir:
100 tmp = Path(tmpdir)
101 # Stage preprocessed copies under tmp/_async/ so unasync sees a clean
102 # tree without the marker blocks. Mirror directory layout.
103 staged: list[str] = []
104 for relpath in async_files:
105 src = SRC / relpath
106 dst = tmp / relpath
107 dst.parent.mkdir(parents=True, exist_ok=True)
108 dst.write_text(REMOVE_BLOCK.sub("", src.read_text()))
109 staged.append(str(dst))
110
111 rule = unasync.Rule(
112 fromdir=str(tmp / "_async") + "/",
113 todir=str(SRC / "_sync") + "/",
114 additional_replacements=REPLACEMENTS,
115 )
116 unasync.unasync_files(staged, [rule])
117
118 # Prepend the "do not edit" header to every generated file. unasync
119 # writes its output verbatim, so the header has to be added after the
120 # fact rather than as part of the rule.
121 for path in sync_dir.rglob("*.py"):
122 path.write_text(GENERATED_HEADER + path.read_text())
123
124 print(f"✓ generated {sync_dir.relative_to(ROOT)} from _async/")
125
126
127if __name__ == "__main__":

Callers 1

run_unasync.pyFile · 0.70

Calls 1

discover_async_filesFunction · 0.85

Tested by

no test coverage detected