migrate.py 717 Bytes
Newer Older
Mitar's avatar
Mitar committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/usr/bin/env python3

# This is a helper Python script. See "migrate.sh" for the main script to call.
#
# This helper is just changing the interface version string in JSON. This simple approach might
# fail though if other aspects of a primitive annotation changed (like docstrings).
# In that case you might want to update this script to add do more changes when migrating.

import json
import sys

to_version = sys.argv[1]

for filename in sys.argv[2:]:
    with open(filename, 'r') as file:
        primitive_annotation = json.load(file)

Mitar's avatar
Typo.  
Mitar committed
18
    primitive_annotation['primitive_code']['interfaces_version'] = to_version
Mitar's avatar
Mitar committed
19 20 21

    with open(filename, 'w') as file:
        json.dump(primitive_annotation, file, indent=4)