blob: ff08d8435dd8c934ee1be361098577d90ea36bcf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#!/usr/bin/python
import sys
import json
import subprocess
new_file = open(sys.argv[2]).read()
new_data = json.loads(new_file)
perl_json = subprocess.Popen('perl -MJSON -le "do shift; print to_json('
'\%param)" ' + sys.argv[1], shell=True,
stdout=subprocess.PIPE).stdout.read()
old_data = json.loads(perl_json)
merged_data = {}
for key, value in new_data.iteritems():
if key in old_data:
merged_data[key] = old_data[key]
else:
merged_data[key] = new_data[key]
print json.dumps(merged_data, indent=4, sort_keys=True)
|