Created
November 28, 2015 12:05
-
-
Save simogasp/7c9aa5cd0f3bf955ee42 to your computer and use it in GitHub Desktop.
script to convert a sfm_data file to the new format with polymorphic views
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Sat Nov 28 11:27:30 2015 | |
@author: sgaspari | |
""" | |
import json | |
import argparse | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser(description='Convert a sfm_data into the new format with polymorphic View') | |
parser.add_argument('-i', '--inputsfm', required=True, help='The sfm data file to convert') | |
parser.add_argument('-o', '--outputsfm', required=True, help='The name of the converted sfm data file') | |
args = parser.parse_args() | |
#with open('sfm_dataTestVersion.json') as data_file: | |
with open(args.inputsfm) as data_file: | |
data = json.load(data_file) | |
numView = len(data['views']) | |
print('Found ' + str(numView) + ' Views') | |
# apparently it adds the same value to all the views | |
for i in range(numView): | |
data['views'][i]['value']["polymorphic_id"] = 1073741824; | |
# data['views'][0]['value']["polymorphic_id"] = 213123; | |
# print(data['views'][1]['value']["polymorphic_id"]) | |
# print(data['views'][0]['value']["polymorphic_id"]) | |
# print(data['views'][1]['key']) | |
# print(data['views'][1]['value']['ptr_wrapper']['id']) | |
#with open('test.json', 'w') as outfile: | |
with open(args.outputsfm, 'w') as outfile: | |
json.dump(data, outfile, indent=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment