Created
July 22, 2020 02:05
-
-
Save rkrishnasanka/8bf7970180e0f5be37691ed95df57710 to your computer and use it in GitHub Desktop.
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/python3 | |
import json | |
from os import close | |
import sys | |
device = {} | |
with open(sys.argv[1]) as json_file: | |
device = json.load(json_file) | |
# Delete Orientation for the valves | |
for component in device['components']: | |
if component['entity'] == 'VALVE3D' or component['entity'] == 'VALVE': | |
params = component['params'] | |
if 'orientation' in params.keys(): | |
print(params) | |
del params['orientation'] | |
print(params) | |
for feature_layers in device['features']: | |
feature_keys = feature_layers['features'].keys() | |
for key in feature_keys: | |
feature = feature_layers['features'][key] | |
if feature['macro'] == 'Valve' or feature['macro'] == 'Valve3D' or feature['macro'] == 'Valve3D_control': | |
params = feature['params'] | |
if 'orientation' in params: | |
del params['orientation'] | |
print(params) | |
json_file.close() | |
with open(sys.argv[1], 'w') as outfile: | |
json.dump(device, outfile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment