Move python scripts outside of game dir

This commit is contained in:
OleSTEEP 2024-01-15 18:17:04 +03:00
parent 6b717a39f7
commit 8ea7a858d0
2 changed files with 2 additions and 2 deletions

View file

@ -1,30 +0,0 @@
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)