Skip to content

Instantly share code, notes, and snippets.

@nanonyme
Last active August 22, 2020 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nanonyme/f7e989048f4d4973daf10c42f574a289 to your computer and use it in GitHub Desktop.
Save nanonyme/f7e989048f4d4973daf10c42f574a289 to your computer and use it in GitHub Desktop.
#!/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