-
-
Save abderrahim/b08a0974dbecdc16726054a61635f55d to your computer and use it in GitHub Desktop.
This file contains 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 | |
from ruamel 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.round_trip_load(file) | |
for project in list(data["projects"]): | |
for element in list(data["projects"][project]): | |
if not valid(element): | |
del data["projects"][project][element] | |
with open(filename, "w") as file: | |
yaml.round_trip_dump(data, file) | |
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