mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2024-11-05 13:43:56 +01:00
31 lines
675 B
Python
31 lines
675 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
import os
|
||
|
import os.path
|
||
|
import json
|
||
|
|
||
|
|
||
|
def main():
|
||
|
|
||
|
d = {}
|
||
|
os.chdir("static")
|
||
|
try:
|
||
|
os.remove(os.path.join("data","database.json"))
|
||
|
except FileNotFoundError:
|
||
|
pass
|
||
|
for root, dirs, files in os.walk('data'):
|
||
|
for name in files:
|
||
|
filename = os.path.join(root,name)
|
||
|
with open(filename,'r',encoding="utf8") as f:
|
||
|
try:
|
||
|
d["/"+filename] = f.read()
|
||
|
except UnicodeDecodeError:
|
||
|
pass
|
||
|
|
||
|
with open(os.path.join("data","database.json"),'w') as f:
|
||
|
f.write(json.dumps(d,indent=1))
|
||
|
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
main()
|