Store JSON in Python for instance types
This allows it to be bundled in the distributed app more simply
This commit is contained in:
parent
a06145d781
commit
4c1d0c3f5f
5 changed files with 2178 additions and 4 deletions
|
|
@ -141,10 +141,20 @@ def main():
|
|||
result[instance_id] = instance_data
|
||||
|
||||
root_dir = subprocess.check_output(['git', 'rev-parse', '--show-toplevel']).decode().strip()
|
||||
dest = os.path.join(root_dir, 'moto/ec2/resources/instance_types.json')
|
||||
dest = os.path.join(root_dir, 'moto/ec2/resources/instance_types.py')
|
||||
print("Writing data to {0}".format(dest))
|
||||
with open(dest, 'w') as open_file:
|
||||
json.dump(result, open_file)
|
||||
triple_quote = '\"\"\"'
|
||||
|
||||
open_file.write("# Imported via `scripts/get_instance_info.py`\n")
|
||||
open_file.write('instance_types_data = {}\n'.format(triple_quote))
|
||||
json.dump(result,
|
||||
open_file,
|
||||
sort_keys=True,
|
||||
indent=4,
|
||||
separators=(',', ': '))
|
||||
open_file.write('{}\n'.format(triple_quote))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue