3
|
1 #!/usr/bin/env python
|
|
2
|
|
3
|
|
4 import json, sys
|
|
5
|
|
6 with open(sys.argv[1]) as file:
|
|
7 data = json.load(file)
|
|
8 tool = {}
|
|
9 for i in range(len(data['steps'].keys())):
|
|
10 tool[i] = {}
|
|
11
|
|
12 print data['steps'][str(i)]['id']
|
|
13 tool[i]['step_number'] = data['steps'][str(i)]['id']
|
|
14 print data['steps'][str(i)]['name']
|
|
15 tool[i]['name'] = data['steps'][str(i)]['name']
|
|
16 print data['steps'][str(i)]['tool_version']
|
|
17 tool[i]['tool_version'] = data['steps'][str(i)]['tool_version']
|
|
18 print data['steps'][str(i)]['tool_id']
|
|
19 tool[i]['tool_id'] = data['steps'][str(i)]['tool_id']
|
|
20 tool[i]['input_list'] = []
|
|
21 for step in data['steps'][str(i)]['inputs']:
|
|
22 print step['name'], step['description']
|
|
23 a = {'name': step['name'], 'description': step['description']}
|
|
24 tool[i]['input_list'].append(a)
|
|
25 print ''
|
|
26 tool[i]['output_list'] = []
|
|
27 for step in data['steps'][str(i)]['outputs']:
|
|
28 print step['name'], step['type']
|
|
29 a = {'name': str(step['name']+'.'+step['type']), 'type': step['type']}
|
|
30 # tool[i]['output_list']['address'] =
|
|
31 tool[i]['output_list'].append(a)
|
|
32 print '\n'
|
|
33 json_data = json.dumps(tool)
|
|
34
|
|
35 for i in tool:
|
|
36 print json.dumps(tool[i])
|
|
37
|
|
38 print type(tool.keys())
|
|
39
|
|
40 with open(sys.argv[2], 'w') as file:
|
|
41 file.write('[')
|
|
42 for i in tool.keys():
|
|
43 file.write(json.dumps(tool[i], sort_keys=True, indent=4))
|
|
44 if i == tool.keys()[-1]: continue
|
|
45 else: file.write(',')
|
|
46 file.write(']')
|
|
47
|