Last active
August 22, 2020 15:16
-
-
Save nanonyme/f7e989048f4d4973daf10c42f574a289 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import yaml | |
import sys | |
import os | |
import os.path | |
def valid(element_name): | |
return os.path.exists(f"elements/{element_name}") | |
def main(filename): | |
with open(filename) as file: | |
data = yaml.load(file, Loader=yaml.CLoader) | |
for project, elements in data["projects"].items(): | |
data["projects"][project] = {key: value for key, value in elements.items() if valid(key)} | |
with open(filename, "w") as file: | |
yaml.dump(data, file, Dumper=yaml.CDumper) | |
if __name__ == "__main__": | |
main(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment