Initial Commit

This commit is contained in:
OleSTEEP 2023-12-29 23:09:55 +03:00
commit ec5c71b3ac
1712 changed files with 1767257 additions and 0 deletions

30
www/create_listing.py Normal file
View file

@ -0,0 +1,30 @@
from json import dumps
from pathlib import Path
import os
import time
SKIPLIST = ('_DIRECTORY.json',)
DIRECTORIES_SUPPLIED = ['img', 'audio', 'maps', 'data']
def legal_file_name(fname: str) -> bool:
return not (fname in SKIPLIST or fname.startswith('.'))
def create_listing(path: Path, indent: int = 0) -> None:
files = [n for n in os.listdir(path) if legal_file_name(n)]
with open(path / '_DIRECTORY.json', 'w') as fp:
fp.write(dumps(files))
print(' ' * (indent * 2) + f'>> Wrote listing for {path}')
for file in files:
rel_path = path / Path(file)
if rel_path.is_dir():
create_listing(rel_path, indent + 1)
for directory in DIRECTORIES_SUPPLIED:
print(f'>> Beginning of writing listing of the {directory}')
time.sleep(2)
create_listing(Path(directory), 1)