[F] Generator: Mkdirs if not already exists

pull/1/head
Hykilpikonna 2021-11-12 13:59:05 -05:00
parent a6d8e7d531
commit 0d9198806f
1 changed files with 2 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import io import io
import os, json5 import os, json5
from pathlib import Path
if __name__ == '__main__': if __name__ == '__main__':
output = [] output = []
@ -10,5 +11,6 @@ if __name__ == '__main__':
o = json5.load(f) o = json5.load(f)
output.append({'path': p, 'id': o['id'], 'name': o['name'], 'profileUrl': o['profileUrl']}) output.append({'path': p, 'id': o['id'], 'name': o['name'], 'profileUrl': o['profileUrl']})
Path("generated").mkdir(parents=True, exist_ok=True)
with io.open('generated/people-list.json5', 'w', encoding='utf-8') as f: with io.open('generated/people-list.json5', 'w', encoding='utf-8') as f:
f.write(json5.dumps(output, indent=2, ensure_ascii=False)) f.write(json5.dumps(output, indent=2, ensure_ascii=False))