Add files via upload
This commit is contained in:
45
scripts/cucholix/format_repo.py
Normal file
45
scripts/cucholix/format_repo.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import re
|
||||||
|
import unicodedata
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def sanitize_name(name):
|
||||||
|
normalized = unicodedata.normalize('NFKD', name).encode('ascii', 'ignore').decode('ascii')
|
||||||
|
return normalized.replace("'", "").replace("’", "").replace("`", "").replace('"', '')
|
||||||
|
|
||||||
|
def create_formatted_structure(root_folder):
|
||||||
|
formatted_path = os.path.join(root_folder, 'formatted')
|
||||||
|
os.makedirs(formatted_path, exist_ok=True)
|
||||||
|
print(f"Creating formatted structure at: {formatted_path}")
|
||||||
|
|
||||||
|
for root, dirs, files in os.walk(root_folder):
|
||||||
|
for file in files:
|
||||||
|
if file.endswith('.pchtxt'):
|
||||||
|
version = file.replace('.pchtxt', '').strip()
|
||||||
|
|
||||||
|
# Determine game name: it's the folder just above the .pchtxt file
|
||||||
|
game_name = os.path.basename(os.path.dirname(os.path.join(root, file)))
|
||||||
|
game_name = sanitize_name(game_name)
|
||||||
|
|
||||||
|
mod_name = "Graphics Mods"
|
||||||
|
target_dir = os.path.join(formatted_path, f"{game_name} - {mod_name}")
|
||||||
|
os.makedirs(target_dir, exist_ok=True)
|
||||||
|
|
||||||
|
source_path = os.path.join(root, file)
|
||||||
|
dest_path = os.path.join(target_dir, f"{version}.pchtxt")
|
||||||
|
|
||||||
|
shutil.copy2(source_path, dest_path)
|
||||||
|
print(f"Copied {source_path} → {dest_path}")
|
||||||
|
|
||||||
|
def main(folder_path):
|
||||||
|
create_formatted_structure(folder_path)
|
||||||
|
print("Done!")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print("Usage: python collect_graphics_mods.py /path/to/root/folder")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
folder_path = sys.argv[1]
|
||||||
|
main(folder_path)
|
||||||
Reference in New Issue
Block a user