Files
jspg/scripts/update_fixtures.py

34 lines
991 B
Python

import json
import os
fixtures_dir = 'fixtures'
for filename in os.listdir(fixtures_dir):
if not filename.endswith('.json'):
continue
filepath = os.path.join(fixtures_dir, filename)
with open(filepath, 'r') as f:
try:
data = json.load(f)
except json.JSONDecodeError:
print("Failed to parse", filepath)
continue
changed = False
for suite in data:
db = suite.get('database', {})
if 'schemas' in db:
if 'types' not in db:
db['types'] = []
for id_str, schema in db['schemas'].items():
target_type = {
'name': id_str,
'schemas': { id_str: schema }
}
db['types'].append(target_type)
del db['schemas']
changed = True
if changed:
with open(filepath, 'w') as f:
json.dump(data, f, indent=2)
print("Updated", filepath)