Write project files to sandbox. If paths is provided, limits writes to those project-relative files; otherwise writes the entire project mapping.
(
ctx: RunContextWrapper[IDEContext], sandbox: Sandbox, paths: list[str] | None = None
)
| 88 | |
| 89 | |
| 90 | async def sync_project_files( |
| 91 | ctx: RunContextWrapper[IDEContext], sandbox: Sandbox, paths: list[str] | None = None |
| 92 | ) -> int: |
| 93 | """Write project files to sandbox. |
| 94 | |
| 95 | If paths is provided, limits writes to those project-relative files; |
| 96 | otherwise writes the entire project mapping. |
| 97 | """ |
| 98 | to_write: list[dict[str, Any]] = [] |
| 99 | written = 0 |
| 100 | project = ctx.context.project or {} |
| 101 | if paths is None: |
| 102 | iterator = ((p, c) for p, c in project.items()) |
| 103 | else: |
| 104 | norm = {str(p).lstrip("./") for p in paths} |
| 105 | iterator = ((p, project[p]) for p in norm if p in project) |
| 106 | for path, content in iterator: |
| 107 | p = str(path).lstrip("./") |
| 108 | if not p: |
| 109 | continue |
| 110 | try: |
| 111 | b = content.encode("utf-8") |
| 112 | except Exception: |
| 113 | b = bytes(str(content), "utf-8") |
| 114 | to_write.append({"path": p, "content": b}) |
| 115 | written += 1 |
| 116 | for i in range(0, len(to_write), 64): |
| 117 | chunk = to_write[i : i + 64] |
| 118 | await sandbox.write_files(chunk) |
| 119 | return written |
| 120 | |
| 121 | |
| 122 | def parse_env_list(env_list: list[str] | None) -> dict[str, str]: |
no outgoing calls
no test coverage detected