| 40 | const ignore = new Ignore(python, "-"); |
| 41 | |
| 42 | const 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 | |
| 58 | write(".", pyscript); |
| 59 | |