Skip to content

Instantly share code, notes, and snippets.

@foolip
Created July 17, 2018 11:28
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foolip/fc9c3ce05a1bdfdbbfc6edf898c71095 to your computer and use it in GitHub Desktop.
Save foolip/fc9c3ce05a1bdfdbbfc6edf898c71095 to your computer and use it in GitHub Desktop.
Adding spec to web-platform-tests META.yml
#!/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