Created
July 17, 2018 11:28
-
-
Save foolip/fc9c3ce05a1bdfdbbfc6edf898c71095 to your computer and use it in GitHub Desktop.
Adding spec to web-platform-tests META.yml
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/env python3 | |
import json | |
import os.path | |
import yaml | |
# https://stackoverflow.com/a/39681672 | |
class MyDumper(yaml.Dumper): | |
def increase_indent(self, flow=False, indentless=False): | |
return super(MyDumper, self).increase_indent(flow, False) | |
# https://foolip.github.io/day-to-day/specs.json | |
specs = json.load(open('specs.json')) | |
for spec in specs: | |
paths = spec['testpath'].split() if 'testpath' in spec else [spec['id']] | |
for path in paths: | |
meta_yml = os.path.join(path, 'META.yml') | |
if not os.path.exists(meta_yml): | |
#print('No {}'.format(meta_yml)) | |
continue | |
with open(meta_yml, 'r') as f: | |
meta = yaml.load(f) | |
meta['spec'] = spec['href'] | |
with open(meta_yml, 'w+') as f: | |
yaml.dump(meta, stream=f, Dumper=MyDumper, default_flow_style=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment