Only run json.dump once
Rather than dump twice, once for each file, dump once to a variable. Then, while we've got it in memory, strip trailing spaces. It's not required that json output have no trailing spaces, but gerrit shows them as does vim when opening files to look at them. It's easy to rememdy, and we're rolling out some file updates in the next patch anyway. Change-Id: Id3d04655264480b202a58b93a813360003707508
This commit is contained in:
parent
4088c19d86
commit
288127acb0
|
@ -79,10 +79,13 @@ def main():
|
|||
valid = validate.validate_all(schema, mapping, resolver=resolver)
|
||||
|
||||
if valid and '-n' not in sys.argv:
|
||||
json.dump(mapping, open('service-types.json', 'w'), indent=2)
|
||||
versioned_file_name = 'service-types.json.{version}'.format(
|
||||
output = json.dumps(mapping, indent=2)
|
||||
output.replace(' \n', '\n')
|
||||
unversioned_filename = 'service-types.json'
|
||||
versioned_filename = 'service-types.json.{version}'.format(
|
||||
version=mapping['version'])
|
||||
json.dump(mapping, open(versioned_file_name, 'w'), indent=2)
|
||||
for filename in (unversioned_filename, versioned_filename):
|
||||
open(filename, 'w').write(output)
|
||||
|
||||
return int(not valid)
|
||||
|
||||
|
|
Loading…
Reference in New Issue