diff --git a/build.py b/build.py index 7a3cb4d..f570436 100755 --- a/build.py +++ b/build.py @@ -14,20 +14,25 @@ BLACKLIST = [ if __name__ == '__main__': result = [] json_paths = [] - # Let's recursively look for all the JSON files + + + # 1. Let's recursively look for all the JSON files # root_dirs = ["Discord", "Geeko Dark", etc...] root = os.listdir("./") for root_dir in root: - if root_dir in BLACKLIST: + is_dir = os.path.isdir(f"./{root_dir}") + if root_dir in BLACKLIST or not is_dir: continue - is_dir = os.path.isdir(f"./{root_dir}") - if not is_dir: - continue - # if root_Dir is "Discord" then deep_dirs is + # if root_dir is "Discord" then deep_dirs is # deep_dirs = ["Discord-Dark"] + # ./Discord + # └── Discord-Dark + # ├── Discord-Dark-Theme.json + # └── Discord-Dark-Theme.png + deep_dirs = os.listdir(f"./{root_dir}") for deep in deep_dirs: current_path = f"./{root_dir}/{deep}" @@ -41,19 +46,19 @@ if __name__ == '__main__': if file.lower().endswith(".json"): json_paths.append(current_path) print(f"Added {file}") - + elif deep.lower().endswith(".json"): json_paths.append(current_path) print(f"Added {file}") - # Now let's parse all the JSON files + # 2. Now let's parse all the JSON files for json_path in json_paths: with open(json_path, 'r') as file: parsed = json.load(file) result.append(parsed) - # Finally output the themes as an array + # 3. Finally output the themes as a JSON array with open(OUTPUT, 'w') as output: output.write( json.dumps(result, indent=2)