MCPcopy Index your code
hub / github.com/pyscript/pyscript / write

Function write

core/src/stdlib.js:42–56  ·  view source on GitHub ↗
(base, literal)

Source from the content-addressed store, hash-verified

40const ignore = new Ignore(python, "-");
41
42const write = (base, literal) => {
43 for (const [key, value] of entries(literal)) {
44 ignore.path(`${base}/${key}`);
45 ignore.push(`_path = _Path("${base}/${key}")`);
46 if (typeof value === "string") {
47 const code = JSON.stringify(value);
48 ignore.push(`_path.write_text(${code},encoding="utf-8")`);
49 } else {
50 // @see https://github.com/pyscript/pyscript/pull/1813#issuecomment-1781502909
51 ignore.push(`if not _os.path.exists("${base}/${key}"):`);
52 ignore.push(" _path.mkdir(parents=True, exist_ok=True)");
53 write(`${base}/${key}`, value);
54 }
55 }
56};
57
58write(".", pyscript);
59

Callers 1

stdlib.jsFile · 0.70

Calls 2

pathMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected