From 23c17ffbc9f8cc24d9307fea7b6840f5fcf86e75 Mon Sep 17 00:00:00 2001 From: Charles Le Maux Date: Tue, 20 Aug 2024 13:56:15 +0200 Subject: [PATCH] [+] Global version indexer script --- servers/get_versions.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 servers/get_versions.py diff --git a/servers/get_versions.py b/servers/get_versions.py new file mode 100644 index 0000000..4384fd2 --- /dev/null +++ b/servers/get_versions.py @@ -0,0 +1,22 @@ +import os +import json + +def get_subfolders(folder_path): + """Gets all subfolders within a given folder path.""" + return [f for f in os.listdir(folder_path) if os.path.isdir(os.path.join(folder_path, f))] + +def main(): + """Main function to iterate over folders and create JSON output.""" + folders_to_scan = ['paper', 'spigot', 'bukkit'] + subfolder_data = {} + + for folder in folders_to_scan: + subfolders = get_subfolders(folder) + subfolder_data[folder] = subfolders + + with open('versions.json', 'w') as json_file: + json.dump(subfolder_data, json_file, indent=2) + +if __name__ == "__main__": + main() +